Exemplo n.º 1
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.apache.jasper.runtime.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");
      out.write("   \"http://www.w3.org/TR/html4/loose.dtd\">\n");
      out.write("\n");
      out.write("<html>\n");
      out.write("<body>\n");
      out.write('\n');
      out.write('\n');

      PrintWriter write =
          new PrintWriter(
              new BufferedWriter(new FileWriter((getServletContext().getRealPath("/output.csv")))));
      int i;
      String[] NoofBusstop = request.getParameterValues("NoofbusStop");
      String[] routeID = request.getParameterValues("routeID");
      String[] routeInterval = request.getParameterValues("routeInterval");
      String[] busStopID = request.getParameterValues("busStopID");
      String[] busStopName = request.getParameterValues("busStopName");
      String[] busStopDescription = request.getParameterValues("busStopDescription");
      String[] busStopOrder = request.getParameterValues("busStopOrder");
      String[] busStopStatus = request.getParameterValues("busStopStatus");
      String[] busStopPeopleNum = request.getParameterValues("busStopPeopleNum");

      int a = 0;
      int b = 0;
      int count = 0;
      int NoofBusstops = 0;
      out.println(
          "\"routeID\",\"routeInterval \",\"busStopID\",\"busStopName\",\"busStopDescription\",\"busStopOrder\",\"busStopStatus\",\"busStopPeopleNum\"");
      write.println(
          "\"routeID\",\"routeInterval \",\"busStopID\",\"busStopName\",\"busStopDescription\",\"busStopOrder\",\"busStopStatus\",\"busStopPeopleNum\"");

      out.println("<BR>");
      for (i = 0; i < busStopID.length; i++) {

        NoofBusstops = Integer.parseInt(NoofBusstop[b]);
        count++;
        if (count > NoofBusstops) {
          a++;
          b++;
          count = 1;
        }

        out.println(
            routeID[a]
                + ","
                + routeInterval[a]
                + ","
                + busStopID[i]
                + ",\""
                + busStopName[i]
                + "\",\""
                + busStopDescription[i]
                + "\","
                + busStopOrder[i]
                + ","
                + busStopStatus[i]
                + ","
                + busStopPeopleNum[i]
                + "<BR>");

        write.println(
            routeID[a]
                + ","
                + routeInterval[a]
                + ","
                + busStopID[i]
                + ",\""
                + busStopName[i]
                + "\",\""
                + busStopDescription[i]
                + "\","
                + busStopOrder[i]
                + ","
                + busStopStatus[i]
                + ","
                + busStopPeopleNum[i]);
      }

      write.close();

      /*
      out.println(request.getParameter("routeInterval")+"<BR>");
      out.println(request.getParameter("busStopID")+"<BR>");
      out.println(request.getParameter("busStopName")+"<BR>");
      out.println(request.getParameter("busStopDescription")+"<BR>");
      out.println(request.getParameter("busStopOrder")+"<BR>");
      out.println(request.getParameter("busStopStatus")+"<BR>");
      out.println(request.getParameter("busStopPeopleNum")+"<BR>");
      */

      out.write("\n");
      out.write("\n");
      out.write("</body>\n");
      out.write("</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
  public synchronized void service(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();
    try {
      HttpSession session = request.getSession();
      PrintWriter out = response.getWriter();
      nseer_db_backup1 fund_db = new nseer_db_backup1(dbApplication);
      nseer_db_backup1 fund_db1 = new nseer_db_backup1(dbApplication);
      if (fund_db.conn((String) dbSession.getAttribute("unit_db_name"))
          && fund_db1.conn((String) dbSession.getAttribute("unit_db_name"))) {
        counter count = new counter(dbApplication);
        ValidataRecordNumber vrn = new ValidataRecordNumber();
        ValidataTag vt = new ValidataTag();
        ValidataNumber validata = new ValidataNumber();
        try {
          String time = "";
          java.util.Date now = new java.util.Date();
          SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
          time = formatter.format(now);

          String apply_pay_ID = request.getParameter("apply_pay_ID");
          String register_time = request.getParameter("register_time");
          String register = request.getParameter("register");
          String register_ID = request.getParameter("register_ID");
          String bodyc = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
          String remark = exchange.toHtml(bodyc);
          String amount = request.getParameter("amount");
          String[] file_kind = request.getParameterValues("file_kind");
          String[] cost_price_subtotal = request.getParameterValues("cost_price_subtotal");
          int p = 0;
          String file_kinda = ",";
          for (int j = 1; j < file_kind.length; j++) {
            file_kinda += file_kind[j] + ",";
            if (cost_price_subtotal[j].equals("")) cost_price_subtotal[j] = "0";
            StringTokenizer tokenTO4 = new StringTokenizer(cost_price_subtotal[j], ",");
            String cost_price_subtotal1 = "";
            while (tokenTO4.hasMoreTokens()) {
              cost_price_subtotal1 += tokenTO4.nextToken();
            }
            if (!validata.validata(cost_price_subtotal1)) {
              p++;
            }
          }
          int n = 0;
          for (int i = 1; i <= Integer.parseInt(amount); i++) {
            String tem_file_kind = "file_kind" + i;
            String file_kind2 = request.getParameter(tem_file_kind);
            if (file_kinda.indexOf(file_kind2) != -1) n++;
          }
          if (n == 0) {
            if (p == 0) {
              if (vt.validata(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "fund_apply_pay",
                          "apply_pay_ID",
                          apply_pay_ID,
                          "check_tag")
                      .equals("5")
                  || vt.validata(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "fund_apply_pay",
                          "apply_pay_ID",
                          apply_pay_ID,
                          "check_tag")
                      .equals("9")) {
                String currency_name = "";
                String personal_unit = "";
                String chain_ID = "";
                String chain_name = "";
                String funder = "";
                String funder_ID = "";
                String sql11 =
                    "select * from fund_apply_pay where apply_pay_ID='" + apply_pay_ID + "'";
                ResultSet rs11 = fund_db.executeQuery(sql11);
                while (rs11.next()) {
                  chain_ID = rs11.getString("chain_ID");
                  chain_name = rs11.getString("chain_name");
                  funder = rs11.getString("human_name");
                  funder_ID = rs11.getString("human_ID");
                  currency_name = rs11.getString("currency_name");
                  personal_unit = rs11.getString("personal_unit");
                }
                int expenses_amount = 0;
                String sql6 =
                    "select count(*) from fund_apply_pay_details where apply_pay_ID='"
                        + apply_pay_ID
                        + "'";
                ResultSet rs6 = fund_db.executeQuery(sql6);
                if (rs6.next()) {
                  expenses_amount = rs6.getInt("count(*)");
                }
                double demand_cost_price_sum = 0.0d;
                for (int i = 1; i <= expenses_amount; i++) {
                  String tem_cost_price_subtotal = "cost_price_subtotal" + i;
                  String cost_price_subtotal2 = request.getParameter(tem_cost_price_subtotal);
                  demand_cost_price_sum += Double.parseDouble(cost_price_subtotal2);
                  sql6 =
                      "update fund_apply_pay_details set cost_price_subtotal='"
                          + cost_price_subtotal2
                          + "' where apply_pay_ID='"
                          + apply_pay_ID
                          + "' and details_number='"
                          + i
                          + "'";
                  fund_db.executeUpdate(sql6);
                }
                for (int i = 1; i < file_kind.length; i++) {
                  StringTokenizer tokenTO1 = new StringTokenizer(file_kind[i], "/");
                  String file_chain_ID = "";
                  String file_chain_name = "";
                  while (tokenTO1.hasMoreTokens()) {
                    file_chain_ID = tokenTO1.nextToken();
                    file_chain_name = tokenTO1.nextToken();
                  }
                  StringTokenizer tokenTO4 = new StringTokenizer(cost_price_subtotal[i], ",");
                  String cost_price_subtotal1 = "";
                  while (tokenTO4.hasMoreTokens()) {
                    cost_price_subtotal1 += tokenTO4.nextToken();
                  }
                  demand_cost_price_sum += Double.parseDouble(cost_price_subtotal1);
                  expenses_amount++;
                  String sql1 =
                      "insert into fund_apply_pay_details(apply_pay_ID,details_number,file_chain_ID,file_chain_name,cost_price_subtotal) values ('"
                          + apply_pay_ID
                          + "','"
                          + expenses_amount
                          + "','"
                          + file_chain_ID
                          + "','"
                          + file_chain_name
                          + "','"
                          + cost_price_subtotal1
                          + "')";
                  fund_db.executeUpdate(sql1);
                }

                String sql =
                    "update fund_apply_pay set demand_cost_price_sum='"
                        + demand_cost_price_sum
                        + "',check_tag='2',register_time='"
                        + register_time
                        + "',register='"
                        + register
                        + "',remark='"
                        + remark
                        + "' where apply_pay_ID='"
                        + apply_pay_ID
                        + "'";
                fund_db.executeUpdate(sql);

                response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=2");
              } else {
                response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=3");
              }
            } else {
              response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=6");
            }
          } else {
            response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=7");
          }
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        fund_db.commit();
        fund_db1.commit();
        fund_db.close();
        fund_db1.close();
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemplo n.º 3
0
  public synchronized void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();

    try {
      PrintWriter out = response.getWriter();

      nseer_db_backup1 stock_db = new nseer_db_backup1(dbApplication);
      nseer_db_backup1 crm_db = new nseer_db_backup1(dbApplication);
      if (stock_db.conn((String) dbSession.getAttribute("unit_db_name"))
          && crm_db.conn((String) dbSession.getAttribute("unit_db_name"))) {

        FileKind FileKind = new FileKind();
        ValidataNumber validata = new ValidataNumber();
        ValidataRecord vr = new ValidataRecord();

        counter count = new counter(dbApplication);
        ValidataTag vt = new ValidataTag();
        String register_ID = (String) dbSession.getAttribute("human_IDD");
        String config_id = request.getParameter("config_id");
        String pay_ID = request.getParameter("pay_ID");
        String product_amount = request.getParameter("product_amount");
        int num = Integer.parseInt(product_amount);
        String payer_name = request.getParameter("payer_name");
        String payer_ID = request.getParameter("payer_ID");
        String reason = request.getParameter("reason");
        String not_return_tag = request.getParameter("not_return_tag");
        String register = request.getParameter("register");
        String register_time = request.getParameter("register_time");
        String demand_return_time = request.getParameter("demand_return_time");
        String sales_name = request.getParameter("sales_name");
        String sales_ID = request.getParameter("sales_ID");
        String bodyc = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
        String remark = exchange.toHtml(bodyc);
        String time = "";
        java.util.Date now = new java.util.Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        time = formatter.format(now);
        String[] product_IDn = request.getParameterValues("product_ID");
        String[] amountn = request.getParameterValues("amount");
        if (num == 0 && product_IDn.length == 1) {
          response.sendRedirect("draft/crm/credit_ok_a.jsp?pay_ID=" + pay_ID);
        } else {
          int p = 0;
          for (int i = 1; i <= num; i++) {
            String tem_amount = "amount" + i;
            String amount = request.getParameter(tem_amount);
            if (amount.equals("")) amount = "0";
            if (!validata.validata(amount)) {
              p++;
            }
          }
          int n = 0;
          String product_ID_group = "";
          for (int j = 1; j < product_IDn.length; j++) {
            product_ID_group += product_IDn[j] + ",";
            if (amountn[j].equals("")) amountn[j] = "0";
            if (!validata.validata(amountn[j])) {
              p++;
            }
          }
          for (int i = 1; i <= num; i++) {
            String tem_product_ID = "product_ID" + i;
            String product_ID = request.getParameter(tem_product_ID);
            if (product_ID_group.indexOf(product_ID) != -1) n++;
          }
          if (vt.validata(
                      (String) dbSession.getAttribute("unit_db_name"),
                      "stock_apply_pay",
                      "pay_ID",
                      pay_ID,
                      "check_tag")
                  .equals("9")
              || vt.validata(
                      (String) dbSession.getAttribute("unit_db_name"),
                      "stock_apply_pay",
                      "pay_ID",
                      pay_ID,
                      "check_tag")
                  .equals("5")) {

            if (p == 0) {
              try {
                if (n == 0) {
                  boolean flag = false;
                  List rsList = GetWorkflow.getList(crm_db, "crm_config_workflow", "05");
                  String[] elem = new String[3];
                  if (rsList.size() == 0) {
                    flag = true;
                  }
                  String sqll = "";
                  String[] aaa1 =
                      FileKind.getKind(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "crm_file",
                          "customer_ID",
                          payer_ID);

                  String stock_pay_ID =
                      NseerId.getId("stock/pay", (String) dbSession.getAttribute("unit_db_name"));
                  double demand_amount = 0.0d;
                  double list_price_sum = 0.0d;
                  double cost_price_sum = 0.0d;

                  for (int i = 1; i <= num; i++) {
                    String tem_product_name = "product_name" + i;
                    String tem_product_ID = "product_ID" + i;
                    String tem_available_amount = "available_amount" + i;
                    String tem_amount = "amount" + i;
                    String tem_list_price = "list_price" + i;
                    String tem_cost_price = "cost_price" + i;
                    String tem_type = "type" + i;
                    String tem_amount_unit = "amount_unit" + i;
                    String product_name = request.getParameter(tem_product_name);
                    String product_ID = request.getParameter(tem_product_ID);
                    String available_amount = request.getParameter(tem_available_amount);
                    String amount = request.getParameter(tem_amount);
                    if (amount.equals("")) amount = "0";
                    String list_price2 = request.getParameter(tem_list_price);
                    String cost_price = request.getParameter(tem_cost_price);
                    String type = request.getParameter(tem_type);
                    StringTokenizer tokenTO3 = new StringTokenizer(list_price2, ",");
                    String list_price = "";
                    while (tokenTO3.hasMoreTokens()) {
                      String list_price1 = tokenTO3.nextToken();
                      list_price += list_price1;
                    }
                    String amount_unit = request.getParameter(tem_amount_unit);
                    double list_price_subtotal =
                        Double.parseDouble(list_price) * Double.parseDouble(amount);
                    list_price_sum += list_price_subtotal;
                    double cost_price_subtotal =
                        Double.parseDouble(cost_price) * Double.parseDouble(amount);
                    cost_price_sum += cost_price_subtotal;
                    demand_amount += Double.parseDouble(amount);
                    String sql1 =
                        "update stock_apply_pay_details set amount='"
                            + amount
                            + "',list_price='"
                            + list_price
                            + "',list_price_subtotal='"
                            + list_price_subtotal
                            + "',cost_price='"
                            + cost_price
                            + "',subtotal='"
                            + cost_price_subtotal
                            + "' where pay_ID='"
                            + pay_ID
                            + "' and details_number='"
                            + i
                            + "'";
                    stock_db.executeUpdate(sql1);
                    if (flag) {
                      if (type.equals("物料") || type.equals("外购商品")) {
                        String sql2 =
                            "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                + stock_pay_ID
                                + "','"
                                + i
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + type
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','0','"
                                + amount
                                + "')";
                        stock_db.executeUpdate(sql2);
                      } else if (type.equals("商品") || type.equals("部件") || type.equals("委外部件")) {
                        String sql2 =
                            "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                + stock_pay_ID
                                + "','"
                                + i
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + type
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','0')";
                        stock_db.executeUpdate(sql2);
                      }

                      String sql97 =
                          "select * from crm_salecredit_balance_details where crediter_ID='"
                              + payer_ID
                              + "' and product_ID='"
                              + product_ID
                              + "'";
                      ResultSet rs97 = crm_db.executeQuery(sql97);
                      if (rs97.next()) {
                        double balance_amount =
                            rs97.getDouble("amount") + Double.parseDouble(amount);
                        double balance_cost_price_subtotal =
                            rs97.getDouble("subtotal") + cost_price_subtotal;
                        double balance_list_price_subtotal =
                            rs97.getDouble("list_price_subtotal") + list_price_subtotal;

                        String sql96 =
                            "update crm_salecredit_balance_details set amount='"
                                + balance_amount
                                + "',check_tag='1',subtotal='"
                                + balance_cost_price_subtotal
                                + "',list_price_subtotal='"
                                + balance_list_price_subtotal
                                + "' where crediter_ID='"
                                + payer_ID
                                + "' and product_ID='"
                                + product_ID
                                + "'";
                        crm_db.executeUpdate(sql96);
                      } else {
                        String[] aaa =
                            FileKind.getKind(
                                (String) dbSession.getAttribute("unit_db_name"),
                                "design_file",
                                "product_ID",
                                product_ID);
                        String sql95 =
                            "insert into crm_salecredit_balance_details(chain_ID,chain_name,crediter_chain_ID,crediter_chain_name,product_ID,product_name,list_price,list_price_subtotal,cost_price,subtotal,amount,crediter_ID,crediter_name) values('"
                                + aaa[0]
                                + "','"
                                + aaa[1]
                                + "','"
                                + aaa1[0]
                                + "','"
                                + aaa1[1]
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + payer_ID
                                + "','"
                                + payer_name
                                + "')";
                        crm_db.executeUpdate(sql95);
                      }
                    }
                  }
                  String[] cost_pricen = request.getParameterValues("cost_price");
                  String[] list_pricen = request.getParameterValues("list_price");
                  String[] product_namen = request.getParameterValues("product_name");
                  String[] product_describen = request.getParameterValues("product_describe");
                  String[] amount_unitn = request.getParameterValues("amount_unit");
                  String[] typen = request.getParameterValues("type");
                  for (int i = 1; i < product_IDn.length; i++) {
                    StringTokenizer tokenTO3 = new StringTokenizer(list_pricen[i], ",");
                    String list_price = "";
                    while (tokenTO3.hasMoreTokens()) {
                      String list_price1 = tokenTO3.nextToken();
                      list_price += list_price1;
                    }
                    if (!amountn[i].equals("") && Double.parseDouble(amountn[i]) != 0) {
                      double list_price_subtotal =
                          Double.parseDouble(list_price) * Double.parseDouble(amountn[i]);
                      list_price_sum += list_price_subtotal;
                      double subtotal =
                          Double.parseDouble(cost_pricen[i]) * Double.parseDouble(amountn[i]);
                      cost_price_sum += subtotal;
                      demand_amount += Double.parseDouble(amountn[i]);
                      num++;
                      String sql1 =
                          "insert into stock_apply_pay_details(payer_chain_ID,payer_chain_name,sales_ID,sales_name,payer_ID,payer_name,payer_type,pay_ID,details_number,product_ID,product_name,product_describe,amount,amount_unit,list_price,list_price_subtotal,cost_price,subtotal,type) values ('"
                              + aaa1[0]
                              + "','"
                              + aaa1[1]
                              + "','"
                              + sales_ID
                              + "','"
                              + sales_name
                              + "','"
                              + payer_ID
                              + "','"
                              + payer_name
                              + "','销售赊货','"
                              + pay_ID
                              + "','"
                              + num
                              + "','"
                              + product_IDn[i]
                              + "','"
                              + product_namen[i]
                              + "','"
                              + product_describen[i]
                              + "','"
                              + amountn[i]
                              + "','"
                              + amount_unitn[i]
                              + "','"
                              + list_price
                              + "','"
                              + list_price_subtotal
                              + "','"
                              + cost_pricen[i]
                              + "','"
                              + subtotal
                              + "','"
                              + typen[i]
                              + "')";
                      stock_db.executeUpdate(sql1);
                      // **********************
                      if (rsList.size() == 0) {
                        if (typen[i].equals("物料") || typen[i].equals("外购商品")) {
                          String sql2 =
                              "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                  + stock_pay_ID
                                  + "','"
                                  + num
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + typen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','0','"
                                  + amountn[i]
                                  + "')";
                          stock_db.executeUpdate(sql2);
                        } else if (typen[i].equals("商品")
                            || typen[i].equals("部件")
                            || typen[i].equals("委外部件")) {
                          String sql2 =
                              "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                  + stock_pay_ID
                                  + "','"
                                  + num
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + typen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','0')";
                          stock_db.executeUpdate(sql2);
                        }

                        String sql97 =
                            "select * from crm_salecredit_balance_details where crediter_ID='"
                                + payer_ID
                                + "' and product_ID='"
                                + product_IDn[i]
                                + "'";
                        ResultSet rs97 = crm_db.executeQuery(sql97);
                        if (rs97.next()) {
                          double balance_amount =
                              rs97.getDouble("amount") + Double.parseDouble(amountn[i]);
                          double balance_cost_price_subtotal =
                              rs97.getDouble("subtotal") + subtotal;
                          double balance_list_price_subtotal =
                              rs97.getDouble("list_price_subtotal") + list_price_subtotal;

                          String sql96 =
                              "update crm_salecredit_balance_details set amount='"
                                  + balance_amount
                                  + "',check_tag='1',subtotal='"
                                  + balance_cost_price_subtotal
                                  + "',list_price_subtotal='"
                                  + balance_list_price_subtotal
                                  + "' where crediter_ID='"
                                  + payer_ID
                                  + "' and product_ID='"
                                  + product_IDn[i]
                                  + "'";
                          crm_db.executeUpdate(sql96);
                        } else {
                          String[] aaa =
                              FileKind.getKind(
                                  (String) dbSession.getAttribute("unit_db_name"),
                                  "design_file",
                                  "product_ID",
                                  product_IDn[i]);
                          String sql95 =
                              "insert into crm_salecredit_balance_details(chain_ID,chain_name,crediter_chain_ID,crediter_chain_name,product_ID,product_name,list_price,list_price_subtotal,cost_price,subtotal,amount,crediter_ID,crediter_name) values('"
                                  + aaa[0]
                                  + "','"
                                  + aaa[1]
                                  + "','"
                                  + aaa1[0]
                                  + "','"
                                  + aaa1[1]
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + payer_ID
                                  + "','"
                                  + payer_name
                                  + "')";
                          crm_db.executeUpdate(sql95);
                        }
                      }
                      // ***************************
                    }
                  }
                  String sql =
                      "update stock_apply_pay set reason='"
                          + reason
                          + "',register='"
                          + register
                          + "',register_time='"
                          + register_time
                          + "',demand_return_time='"
                          + demand_return_time
                          + "',register_time='"
                          + register_time
                          + "',register='"
                          + register
                          + "',remark='"
                          + remark
                          + "',demand_amount='"
                          + demand_amount
                          + "',list_price_sum='"
                          + list_price_sum
                          + "',cost_price_sum='"
                          + cost_price_sum
                          + "',not_return_tag='"
                          + not_return_tag
                          + "' where pay_ID='"
                          + pay_ID
                          + "'";
                  stock_db.executeUpdate(sql);
                  if (flag) {
                    sql = "update stock_apply_pay set check_tag='1' where pay_ID='" + pay_ID + "'";
                    stock_db.executeUpdate(sql);
                    if (!vr.validata(
                        (String) dbSession.getAttribute("unit_db_name"),
                        "stock_pay",
                        "reasonexact",
                        pay_ID)) {
                      String sql4 =
                          "insert into stock_pay(pay_ID,reason,reasonexact,reasonexact_details,demand_amount,list_price_sum,cost_price_sum,register,register_time) values('"
                              + stock_pay_ID
                              + "','"
                              + reason
                              + "','"
                              + pay_ID
                              + "','"
                              + payer_name
                              + "','"
                              + demand_amount
                              + "','"
                              + list_price_sum
                              + "','"
                              + cost_price_sum
                              + "','"
                              + register
                              + "','"
                              + register_time
                              + "')";
                      stock_db.executeUpdate(sql4);
                    }

                    String sql98 = "select * from crm_file where customer_ID='" + payer_ID + "'";
                    ResultSet rs98 = crm_db.executeQuery(sql98);
                    if (rs98.next()) {
                      double salecredit_list_price_sum =
                          rs98.getDouble("salecredit_list_price_sum") + list_price_sum;
                      double salecredit_cost_price_sum =
                          rs98.getDouble("salecredit_cost_price_sum") + cost_price_sum;

                      String sql99 =
                          "update crm_file set credit_yes_or_not_tag='1',salecredit_list_price_sum='"
                              + salecredit_list_price_sum
                              + "',salecredit_cost_price_sum='"
                              + salecredit_cost_price_sum
                              + "' where customer_ID='"
                              + payer_ID
                              + "' ";
                      crm_db.executeUpdate(sql99);
                    }
                  } else {
                    sql = "update stock_apply_pay set check_tag='0' where pay_ID='" + pay_ID + "'";
                    stock_db.executeUpdate(sql);
                    Iterator ite = rsList.iterator();
                    while (ite.hasNext()) {
                      elem = (String[]) ite.next();
                      sql =
                          "insert into crm_workflow(config_id,object_ID,describe1,describe2) values ('"
                              + elem[0]
                              + "','"
                              + pay_ID
                              + "','"
                              + elem[1]
                              + "','"
                              + elem[2]
                              + "')";
                      crm_db.executeUpdate(sql);
                    }
                  }

                  response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=8");
                } else {

                  response.sendRedirect(
                      "draft/crm/credit_ok.jsp?finished_tag=7&pay_ID=" + pay_ID + "");
                }
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            } else {

              response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=6&pay_ID=" + pay_ID + "");
            }
          } else {

            response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=9");
          }
        }
        stock_db.commit();
        crm_db.commit();
        stock_db.close();
        crm_db.close();
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemplo n.º 4
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n");
      org.jivesoftware.util.WebManager webManager = null;
      synchronized (_jspx_page_context) {
        webManager =
            (org.jivesoftware.util.WebManager)
                _jspx_page_context.getAttribute("webManager", PageContext.PAGE_SCOPE);
        if (webManager == null) {
          webManager = new org.jivesoftware.util.WebManager();
          _jspx_page_context.setAttribute("webManager", webManager, PageContext.PAGE_SCOPE);
        }
      }
      out.write('\r');
      out.write('\n');

      webManager.init(request, response, session, application, out);
      boolean save = request.getParameter("save") != null;
      boolean success = request.getParameter("success") != null;
      String persistentRosterParam = request.getParameter("persistentEnabled");
      boolean persistentRoster =
          persistentRosterParam == null ? false : persistentRosterParam.equals("true");

      String ignoreSubdomainsParam = request.getParameter("ignoreSubdomains");
      boolean ignnoreSubdomains =
          ignoreSubdomainsParam == null ? false : ignoreSubdomainsParam.equals("true");
      String blockPresencesParam = request.getParameter("blockPresences");
      boolean blockPresences =
          blockPresencesParam == null ? false : blockPresencesParam.equals("true");

      String sparkdiscoParam = request.getParameter("sparkDiscoInfo");
      boolean sparkDiscoInfo = sparkdiscoParam == null ? false : sparkdiscoParam.equals("true");

      String iqLastFilterPram = request.getParameter("iqLastFilter");
      boolean iqLastFilter = iqLastFilterPram == null ? false : iqLastFilterPram.equals("true");

      String mucFilterParam = request.getParameter("mucFilter");
      boolean mucFilter = mucFilterParam == null ? false : mucFilterParam.equals("true");

      String gajimBroadcastParam = request.getParameter("gajimBroadcast");
      boolean gajimBroadcast =
          gajimBroadcastParam == null ? false : gajimBroadcastParam.equals("true");

      String[] componentsEnabled = request.getParameterValues("enabledComponents[]");
      PermissionManager _pmanager = new PermissionManager();
      DatabaseManager _db;

      Map<String, String> errors = new HashMap<String, String>();
      if (save) {
        for (String property : JiveGlobals.getPropertyNames("plugin.remoteroster.jids")) {
          JiveGlobals.deleteProperty(property);
        }
        if (componentsEnabled != null) {
          for (int i = 0; i < componentsEnabled.length; i++) {
            JiveGlobals.setProperty("plugin.remoteroster.jids." + componentsEnabled[i], "true");
            String group = request.getParameter("input_group." + componentsEnabled[i]);
            if (group != null) {
              _pmanager.setGroupForGateway(componentsEnabled[i], group);
            }
          }
        }
        JiveGlobals.setProperty(
            "plugin.remoteroster.persistent", (persistentRoster ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.blockPresences", (blockPresences ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.sparkDiscoInfo", (sparkDiscoInfo ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.iqLastFilter", (iqLastFilter ? "true" : "false"));
        JiveGlobals.setProperty("plugin.remoteroster.mucFilter", (mucFilter ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.gajimBroadcast", (gajimBroadcast ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.ignoreSubdomains", (ignnoreSubdomains ? "true" : "false"));
        response.sendRedirect("rr-main.jsp?success=true");
        return;
      }

      // Get the session manager
      SessionManager sessionManager = webManager.getSessionManager();

      Collection<ComponentSession> sessions = sessionManager.getComponentSessions();

      _db = DatabaseManager.getInstance();

      out.write(
          "\r\n\r\n<html>\r\n<head>\r\n<title>Gojara Settings</title>\r\n<link href=\"./css/rr.css\" rel=\"stylesheet\" type=\"text/css\">\r\n<script src=\"./js/http.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/jquery.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/rr.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/jquery.sparkline.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/jquery.horiz-bar-graph.js\" type=\"text/javascript\"></script>\r\n<!--[if lte IE 8]><script language=\"javascript\" type=\"text/javascript\" src=\"./js/excanvas.min.js\"></script><![endif]-->\r\n<script language=\"javascript\" type=\"text/javascript\" src=\"./js/jquery.flot.js\"></script>\r\n<script language=\"javascript\" type=\"text/javascript\" src=\"./js/jquery.flot.pie.js\"></script>\r\n\r\n<meta name=\"pageID\" content=\"remoteRoster\" />\r\n<meta name=\"helpPage\" content=\"\" />\r\n\r\n</head>\r\n<body>\r\n\r\n\t<p>Any components configured here will allow the external component associated with them full control over their\r\n\t\tdomain within any user's roster. Before enabling Remote Roster Management support for an external component, first\r\n");
      out.write(
          "\t\tconnect it like you would any external component. Once it has connected and registered with Openfire, it's JID should\r\n\t\tshow up below and you can enable Remote Roster support.</p>\r\n\r\n\t");

      if (success) {

        out.write(
            "\r\n\r\n\t<div class=\"jive-success\">\r\n\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class=\"jive-icon\"><img src=\"images/success-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\r\n\t\t\t\t\t<td class=\"jive-icon-label\">Settings saved!</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</tbody>\r\n\t\t</table>\r\n\t</div>\r\n\t<br>\r\n\r\n\t");

      } else if (errors.size() > 0) {

        out.write(
            "\r\n\r\n\t<div class=\"jive-error\">\r\n\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class=\"jive-icon\"><img src=\"images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\r\n\t\t\t\t\t<td class=\"jive-icon-label\">Error saving settings!</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</tbody>\r\n\t\t</table>\r\n\t</div>\r\n\t<br>\r\n\r\n\t");
      }

      out.write(
          "\r\n\r\n\t<form action=\"rr-main.jsp?save\" method=\"post\">\r\n\r\n\t\t<div class=\"jive-contentBoxHeader\">Connected Gateway Components</div>\r\n\t\t<div class=\"jive-contentBox\">\r\n\r\n\t\t\t<p>Select which components you want to enable remote roster on:</p>\r\n\t\t\t");

      boolean gatewayFound = false;
      int i = 0;
      for (ComponentSession componentSession : sessions) {
        if (!componentSession.getExternalComponent().getCategory().equals("gateway")) {
          continue;
        }
        gatewayFound = true;

        long incoming = componentSession.getNumClientPackets();
        long outgoing = componentSession.getNumServerPackets();
        long both = incoming + outgoing;
        int incomingPercent = (int) (incoming * 100 / both);
        int outgoingPercent = (int) (outgoing * 100 / both);

        out.write(
            "\r\n\t\t\t<table class=\"gatewayHeader\">\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class=\"gatewayCheckbox\"><input type=\"checkbox\" name=\"enabledComponents[]\"\r\n\t\t\t\t\t\t\tvalue=\"");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write("\"\r\n\t\t\t\t\t\t\t");
        out.print(
            JiveGlobals.getBooleanProperty(
                    "plugin.remoteroster.jids."
                        + componentSession.getExternalComponent().getInitialSubdomain(),
                    false)
                ? "checked=\"checked\""
                : "");
        out.write(" />\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td class=\"gatewayName\">");
        out.print(componentSession.getExternalComponent().getName());
        out.write(
            "</td>\r\n\t\t\t\t\t\t<td class=\"gatewayIcons\"><img src=\"images/log-16x16.png\" onclick=\"slideToggle('#logs");
        out.print(i);
        out.write(
            "')\"><img\r\n\t\t\t\t\t\t\tsrc=\"images/permissions-16x16.png\" id=\"showPermissions\" onclick=\"slideToggle('#permission");
        out.print(i);
        out.write(
            "')\"><img\r\n\t\t\t\t\t\t\tsrc=\"images/info-16x16.png\" id=\"showConfig\" onclick=\"slideToggle('#config");
        out.print(i);
        out.write(
            "')\"></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t\t<div id=\"config");
        out.print(i);
        out.write(
            "\" class=\"slider\">\r\n\t\t\t\t<div class=\"sildeHeader\">Information</div>\r\n\t\t\t\t<table class=\"configTable\">\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td width=\"200px\">Domain:</td>\r\n\t\t\t\t\t\t\t<td>");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logeven\">\r\n\t\t\t\t\t\t\t<td>Status:</td>\r\n\t\t\t\t\t\t\t<td>Online</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td>Packages Send/Received:</td>\r\n\t\t\t\t\t\t\t<td><dl class=\"browser-data\" title=\"\">\r\n\t\t\t\t\t\t\t\t\t<dt>Incoming</dt>\r\n\t\t\t\t\t\t\t\t\t<dd>");
        out.print(incomingPercent);
        out.write("</dd>\r\n\t\t\t\t\t\t\t\t\t<dt>Outgoing</dt>\r\n\t\t\t\t\t\t\t\t\t<dd>");
        out.print(outgoingPercent);
        out.write(
            "</dd>\r\n\t\t\t\t\t\t\t\t</dl></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t\t<div id=\"permission");
        out.print(i);
        out.write(
            "\" class=\"slider\">\r\n\t\t\t\t<div class=\"sildeHeader\">Access control</div>\r\n\t\t\t\t<table class=\"groupTable\">\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr id=\"loghead\">\r\n\t\t\t\t\t\t\t<td colspan=\"3\">You can limit the access to the external component to an existing group</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td class=\"permissionTableColumn\">Groupname:</td>\r\n\t\t\t\t\t\t\t<td><input class=\"groupInput\" type=\"text\" id=\"groupSearch");
        out.print(i);
        out.write("\"\r\n\t\t\t\t\t\t\t\tname=\"input_group.");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write("\" alt=\"Find Groups\"\r\n\t\t\t\t\t\t\t\tonkeyup=\"searchSuggest('");
        out.print(i);
        out.write("');\" autocomplete=\"off\"\r\n\t\t\t\t\t\t\t\tvalue=\"");
        out.print(
            _pmanager.getGroupForGateway(
                componentSession.getExternalComponent().getInitialSubdomain()));
        out.write("\">\r\n\t\t\t\t\t\t\t\t<div id=\"search_suggest");
        out.print(i);
        out.write(
            "\"></div></td>\r\n\t\t\t\t\t\t\t<td style=\"vertical-align: top;\">\r\n\t\t\t\t\t\t\t\t<div class=\"ajaxloading\" id=\"ajaxloading");
        out.print(i);
        out.write(
            "\"></div>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t\t<div id=\"logs");
        out.print(i);
        out.write("\" class=\"slider\">\r\n\t\t\t\t");

        int iqs =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.IQ"));
        int msgs =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.Message"));
        int rosters =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.Roster"));
        int presences =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.Presence"));

        out.write(
            "\r\n\t\t\t\t<div class=\"sildeHeader\">Logs & Statistics</div>\r\n\r\n\t\t\t\t<table class=\"logtable\">\r\n\t\t\t\t\t<tfoot>\r\n\t\t\t\t\t\t<tr id=\"logfoot\">\r\n\t\t\t\t\t\t\t<td colspan=\"2\">Packages being logged for ");
        out.print(JiveGlobals.getIntProperty("plugin.remoteroster.log.cleaner.minutes", 60));
        out.write(
            "\r\n\t\t\t\t\t\t\t\tminutes\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td><a style=\"float: right;\"\r\n\t\t\t\t\t\t\t\tonClick=\"window.open('liveStats.jsp?component=");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write(
            "','mywindow','width=1200,height=700')\">Show\r\n\t\t\t\t\t\t\t\t\trealtime Log</a>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tfoot>\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr id=\"loghead\">\r\n\t\t\t\t\t\t\t<td width=\"200px\">Paket type</td>\r\n\t\t\t\t\t\t\t<td width=\"100px\">Number</td>\r\n\t\t\t\t\t\t\t<td></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td>IQ</td>\r\n\t\t\t\t\t\t\t<td id=\"logiq");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(iqs);
        out.write("</td>\r\n\t\t\t\t\t\t\t<td rowspan=\"5\"><div id=\"pie");
        out.print(i);
        out.write(
            "\" class=\"graph\"></div></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logeven\">\r\n\t\t\t\t\t\t\t<td>Messages</td>\r\n\t\t\t\t\t\t\t<td id=\"logmsg");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(msgs);
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td>Roster</td>\r\n\t\t\t\t\t\t\t<td id=\"logroster");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(rosters);
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logeven\">\r\n\t\t\t\t\t\t\t<td>Presence</td>\r\n\t\t\t\t\t\t\t<td id=\"logpresence");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(presences);
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td><span style=\"font-weight: bold;\">Total:</span></td>\r\n\t\t\t\t\t\t\t<td><span style=\"font-weight: bold;\">");
        out.print(iqs + msgs + rosters + presences);
        out.write(
            "</span></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\r\n\t\t\t</div>\r\n\r\n\r\n\t\t\t");

        ++i;
      }

      out.write("\r\n\t\t\t");

      if (!gatewayFound) {

        out.write(
            "\r\n\t\t\t<span style=\"font-weight: bold\">No connected external gateway components found.</span>\r\n\t\t\t");
      }

      out.write(
          "\r\n\t\t</div>\r\n\t\t\r\n\t\t\r\n<div class=\"jive-contentBoxHeader\">General Options</div>\r\n<div class=\"jive-contentBox\">\r\n   <table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n   <tbody>\r\n   <tr valign=\"top\">\r\n       <td width=\"100%\">\r\n           <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n           <tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"persistentEnabled\" id=\"GO1\" value=\"true\"\r\n\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td><label for=\"GO1\">Enable persistent Roster</label></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td />\r\n\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">When Persistent-Roster is enabled, contacts will be saved to database and\r\n\t\t\t\t\tno contacts will be deleted\tby GoJara automatically.<br>\t\t\t\t\t\r\n\t\t\t\t\tWhen Persistent-Roster is disabled, contacts will not be saved to database and \r\n\t\t\t\t\tGoJara will automatically delete all Legacy-RosterItems from the OF-Roster of a User upon logout.<br>Enable this if you want to store Gateway contacts in DB. </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"mucFilter\" id=\"GO2\" value=\"true\"\r\n\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.mucFilter", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td><label for=\"GO2\">Only allow internal Jabber Conferences</label></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td />\r\n\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Spectrum might add MUC(Multi User Chat) to supported features\r\n\t\t\t\t\t of some Transports. If this should not be allowed, because only internal Jabber Conferences should be used, GoJara\r\n\t\t\t\t\t can remove these.</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"ignoreSubdomains\" id=\"GO3\" value=\"true\"\r\n\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.ignoreSubdomains", true)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td><label for=\"GO2\">Do not add Subdomains to Roster</label></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td />\r\n\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">If you do not want the gateway itself to show up as a contact on your roster,\r\n\t\t\t\t\tenable this (only happens on registration).\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\r\n           </tbody>\r\n           </table>\r\n       </td>\r\n   </tr>\r\n   </tbody>\r\n   </table>\r\n</div>\r\n\r\n\t\t<br /> <br />\r\n\t\t<div class=\"jive-contentBoxHeader\">Client specific options</div>\r\n\t\t<div class=\"jive-contentBox\">\r\n\t\t\t<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<tr valign=\"top\">\r\n\t\t\t\t\t\t<td width=\"1%\" nowrap class=\"c1\">Spark:</td>\r\n\t\t\t\t\t\t<td width=\"99%\">\r\n\t\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"sparkDiscoInfo\" id=\"SDI\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.sparkDiscoInfo", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"SDI\"> Support jabber:iq:registered feature</label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">If you use Spark clients within your network, it\r\n\t\t\t\t\t\t\t\t\t\t\tmight be necessary to modify the service discovery packets between Spark and the external component. If you\r\n\t\t\t\t\t\t\t\t\t\t\tcheck this RemoteRoster will add the feature \"jabber:iq:registered\" to the disco#info to indicate that the\r\n\t\t\t\t\t\t\t\t\t\t\tClient is registered with the external component.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"iqLastFilter\" id=\"SDI2\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.iqLastFilter", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"SDI\">Reply to jabber:iq:last </label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Some clients try to check how long a contact is already offline.\r\n\t\t\t\t\t\t\t\t\t\t This feature is not supported by spectrum so it won't response to this IQ stanza. To prevent the client from waiting\r\n\t\t\t\t\t\t\t\t\t\t for a response we could answer with a service-unavailable message as described in XEP-12.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"blockPresences\" id=\"SDI3\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.blockPresences", true)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"SDI\">Block presence pushing to rosterItems except gateway</label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Openfire automatically pushes Presences to every Item on your Roster.\r\n\t\t\t\t\t\t\t\t\t\tFor Spark, this means that roster items which are imported through gateway will trigger automatic login, even if you configured\r\n\t\t\t\t\t\t\t\t\t\tSpark to not connect to these gateways on Startup.<br>\r\n\t\t\t\t\t\t\t\t\t\tBlock Presences if you use Spark and do not want to autoconnect.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr valign=\"top\">\r\n\t\t\t\t\t\t<td width=\"1%\" nowrap class=\"c1\">Gajim:</td>\r\n\t\t\t\t\t\t<td width=\"99%\">\r\n\t\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"gajimBroadcast\" id=\"gajimBroadcast\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.gajimBroadcast", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"gajimBroadcast\">Push available presence on startup</label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Enable this if Gojara should push available presences to\r\n\t\t\t\t\t\t\t\t\t\ttransports from your roster on startup. If disabled, you may have to manually send an available presence to the specific \r\n\t\t\t\t\t\t\t\t\t\ttransport to connect to it.<br>Not needed if you add Subdomains to roster + disabled presence blocking.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t</div>\r\n\r\n\r\n\t\t<input type=\"submit\" name=\"save\" value=\"Save Settings\" />\r\n\t</form>\r\n\r\n</body>\r\n</html>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Exemplo n.º 5
0
  public synchronized void service(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();

    try {

      HttpSession session = request.getSession();
      PrintWriter out = response.getWriter();

      nseer_db_backup1 security_db = new nseer_db_backup1(dbApplication);
      if (security_db.conn((String) dbSession.getAttribute("unit_db_name"))) {
        getRecordCount query = new getRecordCount();

        String tablename = request.getParameter("tablename");
        String[] cols = request.getParameterValues("col");

        if (cols == null) {

          response.sendRedirect("hr/config/key/key_register_ok_a.jsp");

        } else {
          String column_group = "";
          for (int i = 0; i < cols.length; i++) {
            column_group += cols[i] + ",";
          }
          column_group = column_group.substring(0, column_group.length() - 1);
          String sql1 =
              "select * from security_publicconfig_key where tablename='" + tablename + "'";
          ResultSet rs = security_db.executeQuery(sql1);
          if (rs.next()) {
            String sql =
                "update security_publicconfig_key set column_group='"
                    + column_group
                    + "' where tablename='"
                    + tablename
                    + "'";
            security_db.executeUpdate(sql);
          } else {
            String sql =
                "insert into security_publicconfig_key(tablename,column_group) values('"
                    + tablename
                    + "','"
                    + column_group
                    + "')";
            security_db.executeUpdate(sql);
          }

          response.sendRedirect("hr/config/key/key_register_ok_b.jsp");
        }
        security_db.commit();
        security_db.close();

      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
    }
  }
Exemplo n.º 6
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;charset=gb2312");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");

      String path = request.getContextPath();
      String basePath =
          request.getScheme()
              + "://"
              + request.getServerName()
              + ":"
              + request.getServerPort()
              + path
              + "/";

      out.write("\r\n");
      out.write("\r\n");

      response.reset();
      response.setContentType("application/msexcel");
      response.setHeader("Content-disposition", "inline;filename=tqgbstudent.xls"); // 定义文件名
      DecimalFormat f = new DecimalFormat("#,##0.00");
      HSSFWorkbook wb = new HSSFWorkbook();
      HSSFSheet sheet = wb.createSheet("sheet1");
      String[] id = request.getParameterValues("id");
      String[] name = request.getParameterValues("name");
      String[] xuehao = request.getParameterValues("xuehao");
      String[] sex = request.getParameterValues("sex");
      String[] sszy = request.getParameterValues("sszy");
      String[] nbzy = request.getParameterValues("nbzy");
      String[] sd = request.getParameterValues("sd");
      String[] nbbd = request.getParameterValues("nbbd");
      String[] cjpm = request.getParameterValues("cjpm");
      String[] beizhu = request.getParameterValues("beizhu");
      String[] tel = request.getParameterValues("tel");

      // 以下以写表头
      // 表头为第一行
      HSSFRow row = sheet.createRow((short) 0);
      // 定义10列
      HSSFCell cell1 = row.createCell((short) 0);
      HSSFCell cell2 = row.createCell((short) 1);
      HSSFCell cell3 = row.createCell((short) 2);
      HSSFCell cell4 = row.createCell((short) 3);
      HSSFCell cell5 = row.createCell((short) 4);
      HSSFCell cell6 = row.createCell((short) 5);
      HSSFCell cell7 = row.createCell((short) 6);
      HSSFCell cell8 = row.createCell((short) 7);
      HSSFCell cell9 = row.createCell((short) 8);
      HSSFCell cell10 = row.createCell((short) 9);
      HSSFCell cell11 = row.createCell((short) 10);

      cell1.setEncoding((short) 1);
      cell1.setCellType(1);
      cell2.setEncoding((short) 1);
      cell2.setCellType(1);
      cell3.setEncoding((short) 1);
      cell3.setCellType(1);
      cell4.setEncoding((short) 1);
      cell4.setCellType(1);
      cell5.setEncoding((short) 1);
      cell5.setCellType(0);
      cell6.setEncoding((short) 1);
      cell6.setCellType(1);
      cell7.setEncoding((short) 1);
      cell7.setCellType(1);
      cell8.setEncoding((short) 1);
      cell8.setCellType(1);
      cell9.setEncoding((short) 1);
      cell9.setCellType(1);
      cell10.setEncoding((short) 1);
      cell10.setCellType(1);
      cell11.setEncoding((short) 1);
      cell11.setCellType(1);
      // 定义表头的内容
      cell1.setCellValue("序号");
      cell2.setCellValue("姓名");
      cell3.setCellValue("学号");
      cell4.setCellValue("性别");
      cell5.setCellValue("硕士专业");
      cell6.setCellValue("拟报博士专业");
      cell7.setCellValue("原硕导");
      cell8.setCellValue("拟报博导");
      cell9.setCellValue("学位课加权成绩排名");
      cell10.setCellValue("备注");
      cell11.setCellValue("联系方式");

      for (int i = 0; i < name.length; i++) {
        // 定义数据从第二行开始
        row = sheet.createRow((short) i + 1);
        cell1 = row.createCell((short) 0);
        cell2 = row.createCell((short) 1);
        cell3 = row.createCell((short) 2);
        cell4 = row.createCell((short) 3);
        cell5 = row.createCell((short) 4);
        cell6 = row.createCell((short) 5);
        cell7 = row.createCell((short) 6);
        cell8 = row.createCell((short) 7);
        cell9 = row.createCell((short) 8);
        cell10 = row.createCell((short) 9);
        cell11 = row.createCell((short) 10);

        cell1.setEncoding((short) 1);
        cell1.setCellType(1);
        cell2.setEncoding((short) 1);
        cell2.setCellType(1);
        cell3.setEncoding((short) 1);
        cell3.setCellType(1);
        cell4.setEncoding((short) 1);
        cell4.setCellType(1);
        cell5.setEncoding((short) 1);
        cell5.setCellType(0);
        cell6.setEncoding((short) 1);
        cell6.setCellType(1);
        cell7.setEncoding((short) 1);
        cell7.setCellType(1);
        cell8.setEncoding((short) 1);
        cell8.setCellType(1);
        cell9.setEncoding((short) 1);
        cell9.setCellType(1);
        cell10.setEncoding((short) 1);
        cell10.setCellType(1);
        cell11.setEncoding((short) 1);
        cell11.setCellType(1);

        // 填充内容
        cell1.setCellValue(id[i]);
        cell2.setCellValue(name[i]);
        cell3.setCellValue(xuehao[i]);
        cell4.setCellValue(sex[i]);
        cell5.setCellValue(sszy[i]);
        cell6.setCellValue(nbzy[i]);
        cell7.setCellValue(sd[i]);
        cell8.setCellValue(nbbd[i]);
        cell9.setCellValue(cjpm[i]);
        cell10.setCellValue(beizhu[i]);
        cell11.setCellValue(tel[i]);
      }
      wb.write(response.getOutputStream());
      response.getOutputStream().flush();
      response.getOutputStream().close();

    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Exemplo n.º 7
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.glassfish.jsp.api.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("<!DOCTYPE html>\n");
      out.write("<html>\n");
      out.write("    <head>\n");
      out.write(
          "        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
      out.write("        <title>Fine</title>\n");
      out.write("        <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">    \n");
      out.write("\n");
      out.write("    </head>\n");
      out.write("    <body style = \"background-image: url(lib2.jpg)\">         \n");
      out.write("    <center>\n");
      out.write("        <h1>Update Fines information</h1>\n");
      out.write("        <form name=\"Update\" action=\"Fines_upd.jsp\">\n");
      out.write("            <table border=\"0\" width=\"3\" cellspacing=\"2\">\n");
      out.write("                <thead>\n");
      out.write("                    <tr>\n");
      out.write("                        <th>Update Fines</th>\n");
      out.write("                        <th></th>\n");
      out.write("                    </tr>\n");
      out.write("                </thead>\n");
      out.write("                <tbody>\n");
      out.write("                    <tr>\n");
      out.write("                        <td>Update Fine table with todays Data</td>\n");
      out.write(
          "                        <td><input type=\"submit\" value=\"Update / View Fines\" name=\"SUBMIT\"/></td>\n");
      out.write("                    </tr>\n");
      out.write("                </tbody>\n");
      out.write("            </table>           \n");
      out.write("        </form>\n");
      out.write("        <h1>Check your Fines Here</h1>\n");
      out.write("        <form name=\"Fines\" action=\"Fines.jsp\">\n");
      out.write("            <table border=\"0\" width=\"3\" cellspacing=\"2\">\n");
      out.write("                <thead>\n");
      out.write("                    <tr>\n");
      out.write("                        <th>Get Fine Details</th>\n");
      out.write("                        <th></th>\n");
      out.write("                    </tr>\n");
      out.write("                </thead>\n");
      out.write("                <tbody>\n");
      out.write("                    <tr>\n");
      out.write("                        <td>Card No</td>\n");
      out.write(
          "                        <td><input type=\"text\" name=\"Card_no\" value=\"\"/></td>\n");
      out.write("                    </tr>\n");
      out.write("                    <tr>\n");
      out.write("                        <td></td>\n");
      out.write(
          "                        <td><input type=\"submit\" value=\"Get Fines\" name=\"SUBMIT\" /></td>\n");
      out.write("                    </tr>\n");
      out.write("                </tbody>\n");
      out.write("            </table>        \n");
      out.write("            ");

      Connection con = null;
      String[] selected_Checkboxes = request.getParameterValues("chk");
      PreparedStatement pst = null;
      ResultSet result = null;
      ResultSet resUpd = null;
      con =
          DriverManager.getConnection(
              "jdbc:mysql://localhost:3306/lbms_db?zeroDateTimeBehavior=convertToNull",
              "root",
              "admin12");
      String Card_no = request.getParameter("Card_no");
      String button = null;
      Date dt = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
      String current_date = sdf.format(dt);
      if (Card_no != null && selected_Checkboxes == null) {
        String selSql =
            "SELECT  l.card_no, SUM(f.fine_amt) AS total_fine, f.paid  "
                + "FROM book_loans l, fines f  "
                + "WHERE l.loan_id = f.loan_id AND "
                + "l.card_no = "
                + Card_no
                + " "
                + "GROUP BY l.card_no";
        pst = con.prepareStatement(selSql);
        result = pst.executeQuery();
        String box = null;
        String paid;
        String pay;
        Boolean chk = false;
        out.println("<table>");
        pay = "<form action='Fines.jsp'>";
        out.println(pay);
        out.println("<tr>");
        out.println("<th>Card No</th>");
        out.println("<th>Fine_Amt</th>");
        out.println("<th>Paid OR Not</th>");
        out.println("</tr>");
        while (result.next()) {
          chk = true;
          paid = "No";
          if (result.getBoolean("f.paid")) {
            paid = "Yes";
          }

          out.println("<tr>");
          out.println(
              "<td>"
                  + result.getInt("l.card_no")
                  + "</td><td>"
                  + result.getString("total_fine")
                  + "</td><td>"
                  + paid
                  + "</td>");
          out.print("<td>");
          box = "<input name='chk' value=" + result.getInt("l.card_no") + " type='checkbox'>";
          out.print(box);
          out.print("</td>");
          out.print("</tr>");
        }

        if (chk == true) {
          out.println("<tr>");
          out.print("<td>");
          button = "<input type='submit' value='Pay Fine' name='Pay'>";
          out.print(button);
          out.print("</td>");
          out.println("</tr>");
        } else {

          out.write(
              "<dialog open> <font color = 'green'>No Fine information. You owe nothing! Thank You</font> </dialog>");
        }
        out.println("</form>");
        out.println("</table>");
      } else if (selected_Checkboxes != null) {
        String sqlLoan = null;
        ResultSet resultLoan = null;
        String sqlUpdFine = null;
        PreparedStatement pstUpd = null;
        String sqlBook = null;
        ResultSet rsltBook = null;
        char chkouts = 'N';

        int length_chk = selected_Checkboxes.length;
        for (int i = 0; i < length_chk; i++) {
          // Check whether the Book is returned before paying the fine.
          sqlBook =
              "SELECT COUNT(loan_id) AS no_chkouts FROM book_loans WHERE card_no = "
                  + selected_Checkboxes[i]
                  + " AND date_in = '0000-00-00' AND due_date < "
                  + current_date
                  + "";
          pst = con.prepareStatement(sqlBook);
          rsltBook = pst.executeQuery();
          while (rsltBook.next()) {
            if (rsltBook.getInt("no_chkouts") > 0) {
              chkouts = 'Y';
            }
          }
          if (chkouts == 'Y') {

            out.write(
                "<dialog open> <font color = 'red'>You have outstanding due checkouts!. Please return the books and then Pay the fine</font> </dialog>");
          }
          // Get the corresponding loan_Ids for each customer from Fines table

          sqlLoan =
              "SELECT loan_id FROM book_loans WHERE card_no = "
                  + selected_Checkboxes[i]
                  + " AND date_in IS NOT NULL AND due_date < date_in";
          pst = con.prepareStatement(sqlLoan);
          resultLoan = pst.executeQuery();
          while (resultLoan.next()) {
            sqlUpdFine =
                "UPDATE fines SET paid = true WHERE loan_id = " + resultLoan.getInt("loan_id") + "";
            pstUpd = con.prepareStatement(sqlUpdFine);
            pstUpd.executeUpdate();
            out.println("Payment Updated Successfully");
          }
        }
      }

      out.write("\n");
      out.write("        </form>        \n");
      out.write("    </center>\n");
      out.write("</body>\n");
      out.write("</html>\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Exemplo n.º 8
0
  public void getEnv(VariableTable vt) {
    Enumeration e = null;
    HttpServletRequest request = (HttpServletRequest) (pageContext.getRequest());
    HttpSession session = request.getSession(false);

    String db_charset = "gb2312";
    String url_charset = null;

    vt.remove("SESSION.LOGINID");
    vt.remove("SESSION.LOGINNAME");
    vt.remove("SESSION.LOGINROLE");

    if (vt.exists("WEBCHART.DB_CHARSET")) {
      db_charset = vt.getString("WEBCHART.DB_CHARSET");
    }

    if (vt.exists("WEBCHART.URL_CHARSET")) {
      url_charset = vt.getString("WEBCHART.URL_CHARSET");
    }

    if (session != null) {
      e = session.getAttributeNames();
      while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        Object value = session.getAttribute(name);
        vt.add(name, java.sql.Types.VARCHAR);
        if (value != null) vt.setValue(name, value.toString());
      }
      vt.add("SESSION.ID", java.sql.Types.VARCHAR);
      vt.setValue("SESSION.ID", session.getId());
      vt.add("SESSION.CREATE", java.sql.Types.VARCHAR);
      vt.setValue(
          "SESSION.CREATE",
          DBOperation.toString(
              new java.util.Date(session.getCreationTime()), "yyyy-MM-dd HH:mm:ss"));
      vt.add("SESSION.ACCESS", java.sql.Types.VARCHAR);
      vt.setValue(
          "SESSION.ACCESS",
          DBOperation.toString(
              new java.util.Date(session.getLastAccessedTime()), "yyyy-MM-dd HH:mm:ss"));
    }
    e = request.getParameterNames();
    while (e.hasMoreElements()) {
      String name = (String) e.nextElement();
      String value = request.getParameter(name);
      ;
      String par_values[] = request.getParameterValues(name);
      name = name.toUpperCase();
      if (name.equalsIgnoreCase("WEBCHART.SECURITY")
          || name.equalsIgnoreCase("WEBCHART.DEFAULTACCESS")
          || name.equalsIgnoreCase("WEBCHART.ALLOW")
          || name.equalsIgnoreCase("WEBCHART.DENY")
          || name.equalsIgnoreCase("WEBCHART.IPSECURITY")
          || name.equalsIgnoreCase("WEBCHART.IPACCESS")
          || name.equalsIgnoreCase("WEBCHART.IPALLOW")
          || name.equalsIgnoreCase("WEBCHART.IPDENY")
          || name.equalsIgnoreCase("WEBCHART.XSLDOC")
          || name.equalsIgnoreCase("WEBCHART.IMAGEONLY")
          || name.equalsIgnoreCase("WEBCHART.XMLDATA")
          || name.equalsIgnoreCase("WEBCHART.LOGSQL")
          || name.equalsIgnoreCase("WEBCHART.DATATYPE")
          || name.equalsIgnoreCase("WEBCHART.URLS")
          || name.equalsIgnoreCase("WEBCHART.TOPURLS")
          || name.equalsIgnoreCase("WEBCHART.TOPCURR")
          || name.equalsIgnoreCase("WEBCHART.LEFTURLS")
          || name.equalsIgnoreCase("WEBCHART.LEFTCURR")
          || name.equalsIgnoreCase("WEBCHART.INPUTS")
          || name.equalsIgnoreCase("WEBCHART.CACHE")
          || name.equalsIgnoreCase("WEBCHART.DATA")
          || name.equalsIgnoreCase("WEBCHART.CSS")
          || name.equalsIgnoreCase("WEBCHART.RELOAD")
          || name.equalsIgnoreCase("WEBCHART.EXPIRE")
          || name.equalsIgnoreCase("WEBCHART.DMLKEY")
          || name.equalsIgnoreCase("WEBCHART.ENGINE")
          || name.equalsIgnoreCase("WEBCHART.EXCELURL")
          || name.equalsIgnoreCase("WEBCHART.DBID")
          || name.equalsIgnoreCase("WEBCHART.DBIDSEED")
          || name.equalsIgnoreCase("WEBCHART.SECUREFIELDS")
          || name.equalsIgnoreCase("WEBCHART.KEEP_CACHE_IMAGE")
          || name.equalsIgnoreCase("WEBCHART.KEEP_CACHE_TIME")
          || name.startsWith("WEBCHART.SECUREMEMO")
          || name.startsWith("WEBCHART.QUERY_")
          || name.startsWith("WEBCHART.HEADHTML_")
          || name.startsWith("WEBCHART.DATAHTML_")
          || name.startsWith("WEBCHART.VARLIST_")
          || name.startsWith("WEBCHART.FORALL_")
          || name.startsWith("WEBCHART.XMLDATA_")
          || name.startsWith("WEBCHART.TABLE_")
          || name.startsWith("WEBCHART.COLUMN_")
          || name.startsWith("SESSION.")) continue;
      if (name.startsWith("WEBCHART.") && !name.equals("WEBCHART.DOCTYPE")) continue;
      vt.add(name, java.sql.Types.VARCHAR);

      if (par_values != null && par_values.length > 1) {
        StringBuffer temp = new StringBuffer();
        for (int i = 0; i < par_values.length; i++) {
          if (par_values[i] != null && par_values[i].trim().length() > 0) {
            if (temp.length() > 0) {
              temp.append(",");
            }
            temp.append(par_values[i]);
          }
        }
        value = temp.toString();
      }
      if (url_charset != null) {
        try {
          value = new String(value.getBytes(url_charset), db_charset);
        } catch (java.io.UnsupportedEncodingException uee) {
        }
        ;
      }
      vt.setValue(name, value);
    }
    vt.add("REQUEST.REMOTEADDR", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.REMOTEADDR", getClientIPAddr());
    vt.add("REQUEST.REMOTEHOST", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.REMOTEHOST", request.getRemoteAddr());
    vt.add("REQUEST.REFERER", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.REFERER", request.getHeader("Referer"));
    vt.add("REQUEST.QUERYSTRING", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.QUERYSTRING", request.getQueryString());
  }