Beispiel #1
0
  protected void performGetArticole() {

    String numeArticol = txtNumeArticol.getText().toString().trim();
    String tipCautare = "", tipArticol = "";

    if (tglButton.isChecked()) tipCautare = "C";
    else tipCautare = "N";

    if (tglTipArtBtn.isChecked()) tipArticol = "S";
    else tipArticol = "A";

    String localDep = UserInfo.getInstance().getCodDepart();

    if (isCV()) {
      localDep = CLPFragment1.departamentConsilier;
    } else if (UtilsUser.isAgentOrSD()) {
      localDep = UserInfo.getInstance().getCodDepart();
    } else if (UtilsUser.isKA()) {
      localDep = "00";
    }

    if (localDep.length() > 0) {
      HashMap<String, String> params = UtilsGeneral.newHashMapInstance();
      params.put("searchString", numeArticol);
      params.put("tipArticol", tipArticol);
      params.put("tipCautare", tipCautare);
      params.put("departament", localDep);

      opArticol.getArticoleDistributie(params);
    }
  }
Beispiel #2
0
 /**
  * This function returns to a logged user he's own information.
  *
  * @param a the authentication object
  * @return the user information or null if wrong authentication
  */
 public UserInfo myUser(Auth a) {
   Integer uid = Auths.getInstance().getUser(a);
   if (uid == null) return null;
   UserInfo user = dbc.loadUser(uid);
   List<Position> ps = dbc.getPositions(user.getId(), 1);
   if (ps.size() > 0) user.setPosition(ps.get(0));
   return new SUserInfo(user);
 }
Beispiel #3
0
 /**
  * Allows the user to change he's own user information
  *
  * @param a the authentication object
  * @param ui the new user information
  * @param pw the new password
  * @return whether it succeed
  */
 public boolean changeUser(Auth a, UserInfo ui, String pw) {
   Integer uid = Auths.getInstance().getUser(a);
   if (uid == null) return false;
   if (uid != ui.getId()) return false;
   User u = new User(ui);
   try {
     if (pw.equals(getHash(""))) pw = dbc.loadUser(ui.getId()).getPassword();
   } catch (NoSuchAlgorithmException e) {
     e.printStackTrace();
   }
   u.setPassword(pw);
   return dbc.saveUser(u);
 }
Beispiel #4
0
  private void performSaveClp() {
    try {

      HashMap<String, String> params = new HashMap<String, String>();

      String localAlertSD = "true";

      // pentru KA nu se cere aprobarea SD-ului local
      if (UserInfo.getInstance().getTipAcces().equals("10")
          || UserInfo.getInstance().getTipAcces().equals("27")) {
        localAlertSD = "false";
      }

      String localDep = UserInfo.getInstance().getCodDepart();

      // consilieri
      if (UserInfo.getInstance().getTipAcces().equals("17")
          || UserInfo.getInstance().getTipAcces().equals("18")) {
        localDep = CLPFragment1.departamentConsilier;
      }

      params.put("comanda", CreareClp.comandaFinala);
      params.put("codAgent", UserInfo.getInstance().getCod());
      params.put("filiala", UserInfo.getInstance().getUnitLog());
      params.put("depart", localDep);
      params.put("alertSD", localAlertSD);
      params.put("serData", operatiiClp.serializeComandaClp(comandaCLP));

      operatiiClp.salveazaComanda(params);

    } catch (Exception e) {
      Toast.makeText(getActivity(), e.toString(), Toast.LENGTH_SHORT).show();
    }
  }
Beispiel #5
0
  private String validateDataToSave() {
    String retVal = "-1";

    if (UserInfo.getInstance().getTipAcces().equals("17")
        || UserInfo.getInstance().getTipAcces().equals("18")) {

      if (CLPFragment1.textSelClient.getText().toString().trim().equals("")) {
        retVal = "Selectati clientul!";
        return retVal;
      }

    } else {
      if (CreareClp.codClient.trim().toString().equalsIgnoreCase("")) {
        retVal = "Selectati clientul!";
        return retVal;
      }
    }

    if (CLPFragment1.radioClient.isChecked()) {
      if (CreareClp.codJudet.trim().toString().equalsIgnoreCase("")) {
        retVal = "Selectati judetul!";
        return retVal;
      }

      if (CreareClp.oras.trim().toString().equalsIgnoreCase("")) {
        retVal = "Completati orasul!";
        return retVal;
      }

      if (CreareClp.strada.trim().toString().equalsIgnoreCase("") && !hasCoordinates()) {
        retVal = "Completati strada sau pozitionati adresa pe harta!";
        return retVal;
      }

      if (!isAdresaCorecta()) {
        retVal = "Completati adresa corect sau pozitionati adresa pe harta.";
        return retVal;
      }

      if (CreareClp.persCont.trim().toString().equalsIgnoreCase("")) {
        retVal = "Completati persoana de contact!";
        return retVal;
      }

      if (CreareClp.telefon.trim().toString().equalsIgnoreCase("")) {
        retVal = "Completati nr. telefon!";
        return retVal;
      }

      if (CLPFragment1.spinnerAgentiCLP.getVisibility() == View.VISIBLE) {
        if (CLPFragment1.spinnerAgentiCLP.getSelectedItemId() == 0) {
          retVal = "Selectati agentul!";
          return retVal;
        }
      }
    }

    if (CreareClp.tipTransport.toUpperCase().equals("TRAP")) {
      if (CreareClp.tipMarfa.trim().toString().equalsIgnoreCase("")) {
        retVal = "Completati tipul de marfa!";
        return retVal;
      }

      if (CreareClp.masaMarfa.trim().toString().equalsIgnoreCase("")) {
        retVal = "Completati masa !";
        return retVal;
      }
    }

    if (CreareClp.tipTransport.toUpperCase().equals("TRAP")
        && CLPFragment1.spinnerTonaj.getSelectedItemPosition() == 0) {
      retVal = "Selectati tonajul!";
      return retVal;
    }

    if (CreareClp.codFilialaDest.trim().toString().equalsIgnoreCase("")) {
      retVal = "Selectati filiala!";
      return retVal;
    }

    return retVal;
  }
Beispiel #6
0
 boolean isCV() {
   return UserInfo.getInstance().getTipUser().equals("CV")
       || UserInfo.getInstance().getTipUser().equals("SM");
 }
Beispiel #7
0
  private String[] getDepozite() {
    List<String> listDepozite = new ArrayList<String>(Arrays.asList(depozite));
    listDepozite.add(UserInfo.getInstance().getCodDepart() + "RZ");

    return listDepozite.toArray(new String[listDepozite.size()]);
  }
Beispiel #8
0
  private void performSaveNewClp() {

    try {

      String articoleFinale = prepareArtForDelivery();

      String depozDest = "";
      String varSelectedDepoz =
          CLPFragment1.spinnerDepozClp_Dest.getSelectedItem().toString().trim();

      if (varSelectedDepoz.contains("-")) {
        String[] tokenDep_Dest = varSelectedDepoz.split("-");
        depozDest = UserInfo.getInstance().getCodDepart() + tokenDep_Dest[0].trim();
      } else {
        depozDest = varSelectedDepoz;
      }

      // agenti
      if (UserInfo.getInstance().getTipAcces().equals("9")
          || UserInfo.getInstance().getTipAcces().equals("27")) {
        CreareClp.selectedAgent = UserInfo.getInstance().getCod();
      }

      String numeClientCV = CLPFragment1.textSelClient.getText().toString().trim();

      String observatiiCLP =
          CLPFragment1.txtObservatiiCLP.getText().toString().isEmpty()
              ? " "
              : CLPFragment1.txtObservatiiCLP.getText().toString();

      String localCodClient = CreareClp.codClient;

      if (UserInfo.getInstance().getTipAcces().equals("17")
          || UserInfo.getInstance().getTipAcces().equals("18")) {
        if (CLPFragment1.radioClientPF.isChecked()) {
          localCodClient =
              InfoStrings.getClientGenericGed(UserInfo.getInstance().getUnitLog(), "PF");
        }

        if (CLPFragment1.radioClientPJ.isChecked()) {
          localCodClient =
              InfoStrings.getClientGenericGed(UserInfo.getInstance().getUnitLog(), "PJ");
        }
      }

      String strTonaj = "-1";

      if (isConditiiTonaj(CreareClp.tipTransport, CLPFragment1.spinnerTonaj)) {
        String[] tonaj = CLPFragment1.spinnerTonaj.getSelectedItem().toString().split(" ");
        strTonaj = tonaj[0];
      }

      AntetComandaCLP antetComandaCLP = new AntetComandaCLP();

      antetComandaCLP.setCodClient(localCodClient);
      antetComandaCLP.setCodJudet(CreareClp.codJudet);
      antetComandaCLP.setLocalitate(CreareClp.oras);
      antetComandaCLP.setStrada(CreareClp.strada.isEmpty() ? " " : CreareClp.strada);
      antetComandaCLP.setPersCont(CreareClp.persCont);
      antetComandaCLP.setTelefon(CreareClp.telefon);
      antetComandaCLP.setCodFilialaDest(CreareClp.codFilialaDest);
      antetComandaCLP.setDataLivrare(CreareClp.dataLivrare);
      antetComandaCLP.setTipPlata(CreareClp.tipPlata);
      antetComandaCLP.setTipTransport(CreareClp.tipTransport);
      antetComandaCLP.setDepozDest(depozDest);
      antetComandaCLP.setSelectedAgent(CreareClp.selectedAgent);
      antetComandaCLP.setCmdFasonate(cmdFasonate);
      antetComandaCLP.setNumeClientCV(numeClientCV);
      antetComandaCLP.setObservatiiCLP(observatiiCLP);
      antetComandaCLP.setTipMarfa(CreareClp.tipMarfa);
      antetComandaCLP.setMasaMarfa(CreareClp.masaMarfa);
      antetComandaCLP.setTipCamion(
          CLPFragment1.spinnerTipCamion
              .getSelectedItem()
              .toString()
              .toUpperCase(Locale.getDefault()));
      antetComandaCLP.setTipIncarcare(
          CLPFragment1.spinnerTipIncarcare
              .getSelectedItem()
              .toString()
              .toUpperCase(Locale.getDefault()));
      antetComandaCLP.setTonaj(strTonaj);

      comandaCLP.setAntetComandaCLP(antetComandaCLP);

      CreareClp.comandaFinala =
          localCodClient
              + "#"
              + CreareClp.codJudet
              + "#"
              + CreareClp.oras
              + "#"
              + CreareClp.strada
              + "#"
              + CreareClp.persCont
              + "#"
              + CreareClp.telefon
              + "#"
              + CreareClp.codFilialaDest
              + "#"
              + CreareClp.dataLivrare
              + "#"
              + CreareClp.tipPlata
              + "#"
              + CreareClp.tipTransport
              + "#"
              + depozDest
              + "#"
              + CreareClp.selectedAgent
              + "#"
              + cmdFasonate
              + "#"
              + numeClientCV
              + "#"
              + observatiiCLP
              + "#"
              + CreareClp.tipMarfa
              + "#"
              + CreareClp.masaMarfa
              + "#"
              + CLPFragment1.spinnerTipCamion
                  .getSelectedItem()
                  .toString()
                  .toUpperCase(Locale.getDefault())
              + "#"
              + CLPFragment1.spinnerTipIncarcare
                  .getSelectedItem()
                  .toString()
                  .toUpperCase(Locale.getDefault())
              + "#"
              + strTonaj
              + "@"
              + articoleFinale;

      performSaveClp();

    } catch (Exception ex) {
      Toast.makeText(getActivity(), ex.toString(), Toast.LENGTH_SHORT).show();
    }
  }
Beispiel #9
0
  @Override
  public void doAction(
      HttpServletRequest req, HttpServletResponse resp, ServletContext context, String url)
      throws ServletException, IOException {
    WebApplicationContext webContext = WebApplicationContextUtils.getWebApplicationContext(context);
    FriendDao friendDao = (FriendDao) webContext.getBean("friendDao");
    BlogDao blogDao = (BlogDao) webContext.getBean("blogDao");
    BMessageDao bMessageDao = (BMessageDao) webContext.getBean("bMessageDao");
    UserInfo userInfo = (UserInfo) req.getSession().getAttribute("userInfo");
    UserInfo toUserInfo = (UserInfo) context.getAttribute("toUserInfo");
    if (url.contains("/Blog/BlogList/")) {
      String sort = url.split("BlogList", 2)[1].replaceFirst("/", "");
      if (!sort.contains("+")) {
        sort = URLDecoder.decode(sort, "utf-8");
      }
      List<Blog> list = blogDao.loadTitle(toUserInfo.getId(), sort);
      if (list.size() != 0) {
        req.setAttribute("blogs", list);
        req.getRequestDispatcher("/Blog/BlogList.jsp").forward(req, resp);
        return;
      } else {
        req.setAttribute("blogs", blogDao.loadTitle(toUserInfo.getId()));
        req.getRequestDispatcher("/Blog/BlogList.jsp").forward(req, resp);
        return;
      }
    } else if (url.endsWith("/Blog/BlogList")) {
      req.setAttribute("blogs", blogDao.loadTitle(toUserInfo.getId()));
      req.getRequestDispatcher("/Blog/BlogList.jsp").forward(req, resp);
      return;
    } else if (url.contains("/Blog/ViewBlog/")) {
      if (userInfo != null) {
        List<Inform> informs = InformBox.get(userInfo.getId());
        if (informs != null) {
          Iterator<Inform> it = informs.iterator();
          while (it.hasNext()) {
            Inform inform = it.next();
            if (inform.getType() == "blog") {
              it.remove();
            }
          }
        }
      }
      String tempurl = url.split("ViewBlog", 2)[1];
      int tempblog_id = 0;
      int temp_id = 0;
      Blog blog = new Blog();
      try {
        tempblog_id = Integer.parseInt(tempurl.replaceFirst("/", ""));
        blog = blogDao.queryByAuthorId(toUserInfo.getId(), tempblog_id);
        temp_id = blog.getId();
        blog.setPageviews(blog.getPageviews() + 1);
        blogDao.update(blog);
      } catch (Exception e) {
        resp.setStatus(404);
        req.getRequestDispatcher("/Error/Error.jsp").forward(req, resp);
        return;
      }
      req.setAttribute("coolblogs", blogDao.loadCoolBlogs(0));
      req.setAttribute("friends", friendDao.load2(toUserInfo));
      req.setAttribute("bmessages", bMessageDao.load(blog.getId()));

      req.getRequestDispatcher("/Blog/ViewBlog.jsp?ID=" + temp_id).forward(req, resp);
      return;
    } else if (url.contains("/Blog/ModifyBlog/")
        && userInfo != null
        && userInfo.getId() == toUserInfo.getId()) {
      String tempurl = url.split("ModifyBlog", 2)[1];
      int tempblog_id = 0;
      int temp_id = 0;
      Blog blog = new Blog();
      try {
        tempblog_id = Integer.parseInt(tempurl.replaceFirst("/", ""));
        blog = blogDao.queryByAuthorId(toUserInfo.getId(), tempblog_id);
        temp_id = blog.getId();
      } catch (Exception e) {
        resp.setStatus(404);
        req.getRequestDispatcher("/Error/Error.jsp").forward(req, resp);
        return;
      }
      req.getRequestDispatcher("/Blog/ModifyBlog.jsp?ID=" + temp_id).forward(req, resp);
      return;
    } else {
      resp.setStatus(404);
      req.getRequestDispatcher("/Error/Error.jsp").forward(req, resp);
      return;
    }
  }