@RequestMapping(value = "/txnadjustment", method = RequestMethod.GET)
  public ModelAndView TxnAdjustment(HttpServletRequest request, ModelMap modelmap) {

    ModelAndView model = new ModelAndView();
    try {
      AuditTrial audit = new AuditTrial();
      HttpSession sessionObj = request.getSession();
      // --audit function start--
      DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      // get current date time with Date()
      Date date = new Date();
      System.out.println("date and time==>" + dateFormat.format(date));

      String adminname = (String) sessionObj.getAttribute("adminname");
      audit.setUsername(adminname);
      audit.setDescription("open the transaction adjuestment");
      audit.setLogdate(dateFormat.format(date));

      int auditid = merchantService.saveAudit(audit);
      // --audit function end--
    } catch (Exception e) {
      e.printStackTrace();
    }
    model.setViewName("uam/txnadjustment");
    return model;
  }
  @RequestMapping(value = "/insertaccountajustment", method = RequestMethod.GET)
  public ModelAndView saveAccountAdjustment(HttpServletRequest request, ModelMap modelmap) {

    ModelAndView model = new ModelAndView();
    try {
      AuditTrial audit = new AuditTrial();
      HttpSession sessionObj = request.getSession();
      AccountAdjustment aa = new AccountAdjustment();
      aa.setDebitaccount(request.getParameter("hiddendebitacct"));
      aa.setCreditaccount(request.getParameter("hiddencreditacct"));
      aa.setAdjustamount(Integer.parseInt(request.getParameter("hiddenadjustacct")));
      aa.setCurrency(request.getParameter("hiddentcurrency"));
      aa.setReason(request.getParameter("hiddenreason"));

      int id = paymentService.saveAccountAdjustment(aa);

      // --audit function start--
      DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      // get current date time with Date()
      Date date = new Date();
      System.out.println("date and time==>" + dateFormat.format(date));

      String adminname = (String) sessionObj.getAttribute("adminname");
      audit.setUsername(adminname);
      audit.setDescription("Insert the account adjustment");
      audit.setLogdate(dateFormat.format(date));

      int auditid = merchantService.saveAudit(audit);
      // --audit function end--

      model.setViewName("uam/acctadjustsuccess");

    } catch (Exception e) {
      e.printStackTrace();
    }
    return model;
  }
  @RequestMapping(value = "/updatedetails", method = RequestMethod.POST)
  public @ResponseBody ModelAndView updateDetails(HttpServletRequest request) {
    System.out.println("In auth updatedetail method");
    ModelAndView model = null;
    try {

      AuditTrial audit = new AuditTrial();
      HttpSession sessionObj = request.getSession();

      String merchantid = request.getParameter("merchantId").trim();
      System.out.println("merchantid" + merchantid);
      String merchantname = request.getParameter("merchantName");
      String merchantemail = request.getParameter("merchantEmailId");
      String merchantdob = request.getParameter("merchantDOB");
      System.out.println("merchantdob" + merchantdob);
      String merchantmobile = request.getParameter("merchantMobile");
      // long mermobile = Long.to(merchantmobile);
      String merchantbusiness = request.getParameter("merchantBusiness");
      String merchantregion = request.getParameter("merchantregion");
      String merchantcountry = request.getParameter("merchantCountry");
      String merchanttel = request.getParameter("merchantTel");
      // long mertel = Long.parseLong(merchanttel);
      String merchantaddress = request.getParameter("merchantAddress");
      System.out.println("merchantaddress" + merchantaddress);
      String merchantmember = request.getParameter("merchantmember");
      String merchanttxnfee = request.getParameter("transactionfee");
      // long mertxn = Long.parseLong(merchanttxnfee);
      String id = request.getParameter("merchant_id");
      long merid = Long.valueOf(id).longValue();
      System.out.println("check" + merid);

      Merchant merchant = new Merchant();
      merchant.setId(merid);
      merchant.setMerchantId(merchantid);
      merchant.setMerchantName(merchantname);
      // merchant.setDOB(merchantdob);
      DateFormat df2 = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");

      Date merchantDOB;
      try {
        merchantDOB = (Date) df2.parse(merchantdob);
        System.out.println("merchantDOB" + merchantDOB);
        merchant.setDOB(merchantDOB);
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      merchant.setMobile(Long.valueOf(merchantmobile).longValue());

      merchant.setEmailId(merchantemail);
      merchant.setTelephone(Long.valueOf(merchanttel).longValue());
      merchant.setBusiness(merchantbusiness);
      merchant.setRegion(merchantregion);
      merchant.setAddress(merchantaddress);
      merchant.setCountry(merchantcountry);
      merchant.setMembershiptype(merchantmember);
      merchant.setTransactionfee(Long.valueOf(merchanttxnfee).longValue());
      merchantService.updatemodifydetails(merchant);

      // --audit process start--
      DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      // get current date time with Date()
      Date date = new Date();
      System.out.println("date and time==>" + dateFormat.format(date));

      String adminname = (String) sessionObj.getAttribute("adminname");
      audit.setUsername(adminname);
      audit.setDescription("Update the merchent '" + merchantname + "'");
      audit.setLogdate(dateFormat.format(date));

      int auditid = merchantService.saveAudit(audit);
      // --audit process end--

      model = new ModelAndView("treatement/searchmerchant");
    } catch (Exception e) {
      e.printStackTrace();
    }
    return model;
  }
  @RequestMapping(value = "/savepermission", method = RequestMethod.POST)
  public ModelAndView savePermission(HttpServletRequest request) {
    System.out.println("In auth userform method");
    ModelAndView model = null;
    AssignRights ar = null;
    try {
      ar = new AssignRights();
      model = new ModelAndView();
      AuditTrial audit = new AuditTrial();
      HttpSession sessionObj = request.getSession();

      // String depid = request.getParameter("departmentId");
      String depname = request.getParameter("department");
      // String desid = request.getParameter("designationId");
      String des = request.getParameter("designation");

      String eid = request.getParameter("employeeId");
      String usname = request.getParameter("userName");
      String bcode = request.getParameter("branchcode");

      String funname[] = request.getParameterValues("hiddenfun");
      String fundes[] = request.getParameterValues("hiddendes");

      for (int s = 0; s < funname.length; s++) {

        String read = request.getParameter("hiddenread" + s);
        String write = request.getParameter("hiddenwrite" + s);
        String del = request.getParameter("hiddendel" + s);

        ar.setDepartmentname(depname);

        ar.setDesignation(des);
        ar.setFunctions(funname[s]);
        ar.setFunctionsdes(fundes[s]);
        ar.setRead(read);
        ar.setWrite(write);
        ar.setDel(del);
        ar.setEmpid(eid);
        ar.setUsername(usname);
        ar.setBranchcode(bcode);

        int v = uamService.savePermission(ar);
      }
      // --insert audit start--

      DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      // get current date time with Date()
      Date date = new Date();
      System.out.println("date and time==>" + dateFormat.format(date));

      String adminname = (String) sessionObj.getAttribute("adminname");
      audit.setUsername(adminname);
      audit.setDescription("Insert the 'Designation & Department Registration'");
      audit.setLogdate(dateFormat.format(date));

      int auditid = merchantService.saveAudit(audit);

      // --insert audit end --

      model.setViewName("acquirer/userdepartmentconfirm");
    } catch (Exception e) {
      e.printStackTrace();
    }

    return model;
  }
  @RequestMapping(value = "/callReject", method = RequestMethod.GET)
  public ModelAndView callReject(HttpServletRequest request, ModelMap modelmap) {

    ModelAndView model = null;
    try {

      String tid = request.getParameter("tid");

      int id = paymentService.callAccpectandReject(tid, 'A');

      // --view the transaction adjustment list --

      AuditTrial audit = new AuditTrial();
      HttpSession sessionObj = request.getSession();
      String[] mount = {
        "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
      };
      String merid = request.getParameter("merchantid");

      String tdate = request.getParameter("tdate");
      String trefno = request.getParameter("trefno");
      String cnumber = request.getParameter("cardnumber");

      modelmap.addAttribute("merid", merid);
      modelmap.addAttribute("tdate", tdate);
      modelmap.addAttribute("trefno", trefno);
      modelmap.addAttribute("cnumber", cnumber);

      List<TransationMonitoring> tmlist = null;
      System.out.println("tdate1===>" + tdate);
      String state = "yes";
      if (!tdate.equals("")) {

        state = "tdate";

        String dateval[] = tdate.split("/");
        String mounth = dateval[0];
        String date = dateval[1];
        String year = dateval[2];

        tdate = date + "-" + mount[Integer.parseInt(mounth) - 1] + "-" + year;
        System.out.println("tdate2===>" + tdate);
        tmlist = paymentService.getTransationMonitoringTDate(merid, tdate);
      }
      if (!trefno.equals("")) {
        state = "trefno";
        tmlist = paymentService.getTransationMonitoringRefno(merid, trefno);
      }
      if (cnumber != null && !cnumber.equals("")) {
        state = "cnumber";
        tmlist = paymentService.getTransationMonitoringCardno(merid, cnumber);
      }
      if (cnumber != null && !trefno.equals("") && !cnumber.equals("")) {
        state = "all";
        tmlist = paymentService.getTransationMonitoringAll(merid, tdate, trefno, cnumber);
      }
      if (state.equals("yes")) {
        if (!merid.equals("")) {
          tmlist = paymentService.getTransationMonitoring(merid);
        }
      }

      // --audit function start--
      DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      // get current date time with Date()
      Date date = new Date();
      System.out.println("date and time==>" + dateFormat.format(date));

      String adminname = (String) sessionObj.getAttribute("adminname");
      audit.setUsername(adminname);
      audit.setDescription("Change the account transaction status for accpect");
      audit.setLogdate(dateFormat.format(date));

      int auditid = merchantService.saveAudit(audit);
      // --audit function end--

      modelmap.addAttribute("tmlist", tmlist);
      model = new ModelAndView("uam/searchtranactionadjustment");

    } catch (Exception e) {
      e.printStackTrace();
    }
    return model;
  }
  @RequestMapping(value = "/saveregistration", method = RequestMethod.POST)
  public ModelAndView saveRegistration(HttpServletRequest request) {

    ModelAndView model = null;
    UserRegistration ur = null;
    try {
      AuditTrial audit = new AuditTrial();
      HttpSession sessionObj = request.getSession();

      ur = new UserRegistration();
      model = new ModelAndView();
      String empid = request.getParameter("employeeId");
      String username = request.getParameter("userName");
      String branchcode = request.getParameter("branchcode");
      String des = request.getParameter("designation");
      String depart = request.getParameter("department");
      String dob = request.getParameter("dob");
      String email = request.getParameter("emailId");

      String mobile = request.getParameter("mobile");
      String tel = request.getParameter("tel");
      String add = request.getParameter("address");
      String count = request.getParameter("country");

      Calendar cal = Calendar.getInstance();
      int year = cal.get(Calendar.YEAR);
      int month = cal.get(Calendar.MONTH);
      int dateval = cal.get(Calendar.DATE);

      System.out.println("year=>" + year);
      System.out.println("month=>" + month);
      System.out.println("dateval=>" + dateval);

      Date curdate = new Date(dateval + "/" + month + "/" + year);

      Date date = new Date(dob);

      ur.setEmpid(empid);
      ur.setName(username);
      ur.setBranchcode(branchcode);
      ur.setDesignation(des);
      ur.setDepartment(depart);

      ur.setDob(date);
      ur.setEmailid(email);
      ur.setMobile(Long.parseLong(mobile));
      ur.setTel(Long.parseLong(tel));
      ur.setAddress(add);
      ur.setCountry(count);

      ur.setCurrentdate(curdate);

      String randomPwd = generateRandomString();
      String encryptedPwd = encrypt(randomPwd);
      System.out.println("merchantId==>" + encryptedPwd);

      ur.setPassword(encryptedPwd);
      // ur.setPassword("password");

      int v = uamService.saveRegistration(ur);

      sendEmailConfirmation(username, encryptedPwd, request, empid, email);

      // --audit start--
      DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      // get current date time with Date()
      Date date1 = new Date();
      System.out.println("date and time==>" + dateFormat.format(date1));

      String adminname = (String) sessionObj.getAttribute("adminname");
      audit.setUsername(adminname);
      audit.setDescription("Insert the user '" + username + "'");
      audit.setLogdate(dateFormat.format(date1));

      int auditid = merchantService.saveAudit(audit);
      // --audit end--

      model.setViewName("acquirer/userregistrationconfirm");
    } catch (Exception e) {
      e.printStackTrace();
    }

    return model;
  }