Beispiel #1
0
  @Override
  public void renderAddEntityForm() {
    try {
      AbsEnt data = getFabric().get("div");
      LinkedHashMap<AbsEnt, String> hs = new LinkedHashMap<AbsEnt, String>();
      hs.put(
          textInput(fieldName, getReq(fieldName), "Сообщение*")
              .setAttribute(EnumAttrType.size, "80"),
          "");
      hs.put(hiddenInput("client_id", getReq("client_id")), "");
      hs.put(hiddenInput("showMenu", renders.entities.client.MENU_COMMENTS), "");

      FormOptionInterface fo = getFormOption(objectName, "add", "add");
      fo.setTitle("ОК");
      setButtonStyle(fo, BUTTON_OK);
      fo.setRenderType(RenderTypes.ajax);
      fo.setJsHandler(JsHandlers.ajax(CONTAINER_ID));
      AbsEnt form = rightForm(hs, fo);
      // AbsEnt form = standartAjaxForm(false, objectName, "add", "add", hs, "ОК",
      // getRenderConstant().OK_IMGPH);
      data.addEnt(form);
      AbsEnt Mw = standartFloatWindow("Добавить комментарий", data);
      addRenderResult(Mw.render());
    } catch (Exception ex) {
      addRenderResult(MyString.getStackExeption(ex));
    }
  }
Beispiel #2
0
 private AbsEnt getAddForm() throws Exception {
   Map<AbsEnt, String> inn = new LinkedHashMap<AbsEnt, String>();
   inn.put(textInput("name", "", "Название"), "");
   AbsEnt ae =
       rightForm(
           Boolean.TRUE, objectName, "add", "add", inn, "Добавить", getRenderConstant().ADD_IMGPH);
   if (ae != null) {
     ae.setAttribute(EnumAttrType.style, "width:100%;position:relative;float:left;");
   }
   return ae;
 }
Beispiel #3
0
 private AbsEnt getAddForm() throws Exception {
   Map<AbsEnt, String> inn = new LinkedHashMap<AbsEnt, String>();
   inn.put(textInput("number", "", "Количество"), "");
   inn.put(combo("userProfile", "getAciveWithComboSurName", null, "user_id", false), "");
   AbsEnt ae =
       rightForm(
           Boolean.TRUE, ObjectName, "add", "add", inn, "Добавить", getRenderConstant().ADD_IMGPH);
   if (ae != null) {
     ae.setAttribute(EnumAttrType.style, "width:100%;position:relative;float:left;");
   }
   return ae;
 }
 private AbsEnt getFormReport() throws Exception {
   Map<AbsEnt, String> param = new LinkedHashMap<AbsEnt, String>();
   param.put(dateInput("active_from", getAr().get("active_from"), "Период от"), "Период от");
   param.put(dateInput("active_to", getAr().get("active_to"), "до"), "до");
   AbsEnt form =
       rightForm(
           Boolean.TRUE,
           ObjectName,
           "getReport",
           "",
           param,
           "Отправить",
           getRenderConstant().OK_IMGPH);
   if (form != null) {
     form.setAttribute(EnumAttrType.style, "width:100%;float:left;");
   }
   return form;
 }
Beispiel #5
0
 private AbsEnt getChangeForm(Object contact_id, Object name, Object number) throws Exception {
   Map<AbsEnt, String> inn = new LinkedHashMap<AbsEnt, String>();
   AbsEnt nt = textInput("number", number, "Количество");
   nt.setAttribute(EnumAttrType.size, "40");
   inn.put(nt, "");
   inn.put(combo("userProfile", "getAciveWithComboSurName", name, "user_id", false), "");
   inn.put(hiddenInput("prolongOption_id", contact_id), "");
   AbsEnt ae =
       rightForm(
           Boolean.TRUE,
           ObjectName,
           "change",
           "change",
           inn,
           "Изменить",
           getRenderConstant().CHANGE_IMGPH);
   return ae;
 }
Beispiel #6
0
  /** просмотр одного */
  @Override
  public void renderOneEntity() {
    try {
      AbsEnt data = div("", "", "profile", null);
      AbsEnt title = div("div", "");
      title.setValue("Тип задач");

      if (!getAr().getDinamicArrayList().isEmpty()) {
        DinamicModel dm = getAr().getDinamicArrayList().get(0);

        data.addEnt(renderParameter("Название: ", dm.get("name")));

        data.addEnt(div("", "{task_type_step:search}"));

        addRenderResult(moduleWindow(objectName, title, data, false).render());
      }
    } catch (Exception ex) {
      registerException(ex);
    }
  }
Beispiel #7
0
  @Override
  public void renderEntityList() {
    try {
      AbsEnt data = div("", "");
      // добавление
      FormOptionInterface afo = getFormOption(objectName, "add", "");
      afo.setTitle("Добавить");
      setButtonStyle(afo, BUTTON_ADD);
      afo.setRenderType(RenderTypes.ajax);
      afo.setJsHandler(JsHandlers.ajax(CONTAINER_ID));
      AbsEnt addForm = rightForm(null, afo);
      // AbsEnt addForm = standartAjaxForm(true, objectName, "add", "", null, "Добавить",
      // fr.getRenderConstant().ADD_IMGPH);
      addForm.addEnt(hiddenInput("client_id", getReq("client_id")));

      addForm.setAttribute(EnumAttrType.style, "float: left; margin-right: 10px; ");
      AbsEnt div = div("", "Комментарии");
      div.addEnt(addForm);

      AbsEnt table = fr.getFabric().get("table").setCss(TABLE_CLASS);
      trTh(table, div);
      for (DinamicModel dm : getActionResult().getDinamicArrayList()) {
        // tr(table, dm.get("message"));
        AbsEnt messageDiv = getFabric().get("div");
        String text =
            dateFormat(dm.get("insert_date"), getRenderConstant().DT_FULL)
                + " "
                + comboLikeString("users", "getAllWithCombo", dm.get("insert_user_id"));
        AbsEnt smallDiv = getFabric().get("div").setValue(text).setCss("small_text");
        messageDiv.addEnt(smallDiv).addEnt(div("", dm.get("message")));
        tr(table, messageDiv);
      }
      data.addEnt(table);
      addRenderResult(data.render());
    } catch (Exception ex) {
      registerException(ex);
    }
  }
Beispiel #8
0
 private AbsEnt getChangeForm(
     Object contact_id, Object name, Object showInLinks, Object daysToDead) throws Exception {
   Map<AbsEnt, String> inn = new LinkedHashMap<AbsEnt, String>();
   AbsEnt nt = textInput("name", name, "Название");
   nt.setAttribute(EnumAttrType.size, "40");
   inn.put(nt, "");
   inn.put(textInput("daysToDead", daysToDead, "Дней до дедлайна"), "");
   inn.put(checkBox("showInLinks", showInLinks), "Отображать в связях");
   inn.put(hiddenInput("task_type_id", contact_id), "");
   AbsEnt ae =
       rightForm(
           Boolean.TRUE,
           objectName,
           "change",
           "change",
           inn,
           "Изменить",
           getRenderConstant().CHANGE_IMGPH);
   if (ae == null) {
     ae = txt(phoneNumberFt(name));
   }
   return ae;
 }
 @Override
 public void renderAddEntityForm() {
   try {
     AbsEnt data = div("position:absolute;width:18%;z-index:1;bottom:100;", null);
     data.addEnt(renderError(ObjectName));
     data.addEnt(renderMessage(ObjectName));
     Map<AbsEnt, String> inn = new HashMap<AbsEnt, String>();
     AbsEnt input = combo("managerPhones", "findActive", null, "manager_phone_id");
     inn.put(input, "");
     AbsEnt ae =
         rightForm(
             Boolean.TRUE,
             ObjectName,
             "add",
             "add",
             inn,
             "Добавить",
             getRenderConstant().ADD_IMGPH);
     data.addEnt(ae);
     addRenderResult(data.render());
   } catch (Exception e) {
     registerException(e);
   }
 }
  /** новый отчет */
  public void report() {
    try {
      // отсортировать по пользователям и по типам
      Map<String, Day> days = new LinkedHashMap();
      List<String> types = new ArrayList();
      Map<String, Integer> sumMap = new LinkedHashMap();
      int totalSumm = 0;

      for (DinamicModel model : getAr().getDinamicArrayList()) {
        if (model.get("insert_user_id") != null
            && model.get("manager_phone_id") != null
            && model.get("date") != null) {
          String date = model.get("date").toString();
          if (!days.containsKey(date)) {
            days.put(date, new Day());
          }

          Day day = days.get(date);
          day.add(model.get("insert_user_id"), model.get("manager_phone_id"), model.get("count"));
          String type = model.get("manager_phone_id").toString();
          if (!types.contains(type)) {
            types.add(type);
          }
        }
      }

      AbsEnt title = div("float:left;", "Отчет по звонкам");
      AbsEnt data = div("float:left;", "");
      data.addEnt(renderError(ObjectName));
      data.addEnt(renderMessage(ObjectName));
      data.addEnt(getFormReport());
      AbsEnt table = getFabric().get("table");
      table.setAttribute(EnumAttrType.border, "1");
      table.setAttribute(EnumAttrType.cellpadding, "5");
      table.setAttribute(EnumAttrType.cellspacing, "5");

      if (!types.isEmpty()) {

        // заголовок таблицы
        AbsEnt th1 = getFabric().get("th");
        AbsEnt tr1 = getFabric().get("tr").addEnt(th1);
        table.addEnt(tr1);
        th1.setValue("Пользователь");
        for (String type : types) {
          String name = comboLikeString("managerPhones", "findActive", type);
          tr1.addEnt(getFabric().get("th").setValue(name));
        }
        tr1.addEnt(getFabric().get("th").setValue("Всего"));

        // по дням
        for (String date : days.keySet()) {

          Map<String, Integer> summMapDay = new LinkedHashMap();
          Integer summDay = 0;

          Day day = days.get(date);

          AbsEnt tdDay = getFabric().get("td");
          AbsEnt trDay = getFabric().get("tr").addEnt(tdDay);
          table.addEnt(trDay);

          Integer colspan = types.size() + 2;
          tdDay.setAttribute(EnumAttrType.colspan, colspan.toString());
          date = dateFormat(date, getRenderConstant().DT_SMALL);
          tdDay.setValue("Дата: " + date);
          tdDay.setAttribute(EnumAttrType.style, "font-weight: bold;");
          Map<String, User> users = day.getUsers();
          // строки по пользователям
          for (String userId : users.keySet()) {
            User user = users.get(userId);
            String userName = comboLikeString("userProfile", "getAllWithComboName", userId);
            AbsEnt td1 = getFabric().get("td");
            AbsEnt tr = getFabric().get("tr");
            table.addEnt(tr.addEnt(td1));
            td1.setValue(userName);
            for (String type : types) {

              Integer count = user.getCount(type);
              if (count == null) {
                count = 0;
              }
              AbsEnt td = getFabric().get("td");
              tr.addEnt(td);
              td.setValue(count);

              // сложить сумму
              if (!sumMap.containsKey(type)) {
                sumMap.put(type, 0);
              }
              if (!summMapDay.containsKey(type)) {
                summMapDay.put(type, 0);
              }
              sumMap.put(type, sumMap.get(type) + count);
              summMapDay.put(type, summMapDay.get(type) + count);
            }
            int summ = user.getSumm();
            totalSumm += summ;
            summDay += summ;
            AbsEnt td2 = getFabric().get("td");
            td2.setValue(summ);
            tr.addEnt(td2);
          }

          // строка с суммой по дню
          AbsEnt tr2 = getFabric().get("tr");
          table.addEnt(tr2);
          tr2.setAttribute(EnumAttrType.style, "font-weight: bold;");
          AbsEnt td1 = getFabric().get("td");
          tr2.addEnt(td1);
          td1.setValue("Всего за день:");
          for (Integer summ : summMapDay.values()) {
            AbsEnt td = getFabric().get("td");
            tr2.addEnt(td);
            td.setValue(summ);
          }

          AbsEnt td2 = getFabric().get("td");
          tr2.addEnt(td2);
          td2.setValue(summDay);
        }

        // строка с итоговой суммой
        AbsEnt tr2 = getFabric().get("tr");
        table.addEnt(tr2);
        tr2.setAttribute(EnumAttrType.style, "font-weight: bold;");
        AbsEnt td1 = getFabric().get("td");
        tr2.addEnt(td1);
        td1.setValue("Всего");
        for (Integer summ : sumMap.values()) {
          AbsEnt td = getFabric().get("td");
          tr2.addEnt(td);
          td.setValue(summ);
        }
        AbsEnt td2 = getFabric().get("td");
        tr2.addEnt(td2);
        td2.setValue(totalSumm);
      }

      data.addEnt(table);
      AbsEnt Mw = moduleWindow(ObjectName, title, data, false);
      Mw.setAttribute(EnumAttrType.style, "margin-top:5px;");
      addRenderResult(Mw.render());
    } catch (Exception e) {
      registerException(e);
    }
  }
Beispiel #11
0
  @Override
  public void renderEntityList() {
    try {
      AbsEnt title = getFabric().get("div");
      title.setValue("Типы  задач");
      AbsEnt data = div("float:left;width:100%;", "");
      AbsEnt table = getFabric().get("table");
      // добавление
      AbsEnt add = simpleAddForm(objectName, null);
      data.addEnt(renderError(objectName));
      data.addEnt(renderMessage(objectName));
      data.addEnt(getAddForm());
      data.addEnt(table);
      for (DinamicModel dm : getAr().getDinamicArrayList()) {
        AbsEnt tr = getFabric().get("tr");
        table.addEnt(tr);
        AbsEnt td = getFabric().get("td");

        tr.addEnt(td);

        AbsEnt td1 = getFabric().get("td");
        td1.addEnt(
            getChangeForm(
                dm.get("task_type_id"),
                dm.get("name"),
                dm.get("showInLinks"),
                dm.get("daysToDead")));
        tr.addEnt(td1);

        AbsEnt td2 = getFabric().get("td");
        tr.addEnt(td2);
        Map<String, Object> mp = new HashMap<String, Object>();
        mp.put("task_type_id", dm.get("task_type_id"));
        AbsEnt form = simpleDeleteForm(objectName, mp);
        td2.addEnt(form);

        AbsEnt td3 = getFabric().get("td");
        HrefOptionInterface ho = getHrefOption(objectName, "showOne", "", "Изменить этапы");
        AbsEnt href = href(mp, ho);
        td3.addEnt(href);
        tr.addEnt(td3);
      }
      AbsEnt Mw = moduleWindow(objectName, title, data, false);
      Mw.setAttribute(EnumAttrType.style, "margin-top:5px;");
      addRenderResult(Mw.render());
    } catch (Exception ex) {
      registerException(ex);
    }
  }
Beispiel #12
0
  @Override
  public void renderEntityList() {
    try {
      AbsEnt title = getFabric().get("div");
      title.setValue("Настройка продлений");
      AbsEnt data = div("float:left;width:100%;", "");
      AbsEnt table = getFabric().get("table");
      // добавление
      AbsEnt add = simpleAddForm(ObjectName, null);
      data.addEnt(renderError(ObjectName));
      data.addEnt(renderMessage(ObjectName));
      data.addEnt(getAddForm());
      data.addEnt(table);
      for (DinamicModel dm : getAr().getDinamicArrayList()) {
        AbsEnt tr = getFabric().get("tr");
        table.addEnt(tr);
        AbsEnt td = getFabric().get("td");

        tr.addEnt(td);

        AbsEnt td1 = getFabric().get("td");
        td1.addEnt(getChangeForm(dm.get("prolongOption_id"), dm.get("user_id"), dm.get("number")));
        tr.addEnt(td1);

        AbsEnt td2 = getFabric().get("td");
        tr.addEnt(td2);
        Map<String, Object> mp = new HashMap<String, Object>();
        mp.put("prolongOption_id", dm.get("prolongOption_id"));
        AbsEnt form = simpleDeleteForm(ObjectName, mp);
        td2.addEnt(form);
      }
      AbsEnt Mw = moduleWindow(ObjectName, title, data, false);
      Mw.setAttribute(EnumAttrType.style, "margin-top:5px;");
      addRenderResult(Mw.render());
    } catch (Exception ex) {
      registerException(ex);
    }
  }
Beispiel #13
0
  /** выслать инвайт по электронной почте */
  private void sendInvite(String email) throws Exception {
    Properties mailProps = new Properties();

    /*
    mailProps.put("mail.transport.protocol", "smtps");
    mailProps.put("mail.smtps.auth", "true");
    mailProps.put("mail.smtps.starttls.enable", "true");

    mailProps.put("mail.smtps.ssl.trust", "*");
    mailProps.put("mail.smtps.ssl.checkserveridentity", "false");

    mailProps.put("mail.smtps.host", HOST);
    mailProps.put("mail.smtps.port", SMTP_PORT);
    mailProps.put("sender.mail.login", POST_LOGIN);
    mailProps.put("sender.mail.password", POST_PASSWORD);
    */

    String host = "smtp.gmail.com";
    String port = "587";
    String mailLogin = "******";
    String mailPassword = "******";

    mailProps.put("mail.transport.protocol", "smtp");
    mailProps.put("mail.smtp.host", host);
    mailProps.put("mail.smtp.auth", "true");
    mailProps.put("mail.smtp.port", port);
    mailProps.put("mail.smtp.starttls.enable", "true");

    mailProps.put("sender.mail.login", mailLogin);
    mailProps.put("sender.mail.password", mailPassword);

    String userName = render.comboLikeString("users", "getAllWithCombo", getAuthorizedUserId());

    Sender sender = Sender.getInstance("mailSender");
    sender.setProps(mailProps);
    com.prim.support.sender.Message mess = new com.prim.support.sender.Message();
    String subject =
        userName + " приглашает Вас воспользоваться новой системой для планирования задач! ";

    AbsEnt link = render.getFabric().get("href").setValue("Ссылка на регистрацию");
    link.setAttribute(
        EnumAttrType.href, "http://" + project.index.LOCAL_IP + "/registration?login="******" приглашает Вас воспользоваться новой системой для планирования задач! "
            + link.render();

    mess.setSubject(subject);
    mess.setTo(email);
    mess.setMessage(message);
    // отправка сообщения, получение результата
    boolean ok = sender.send(mess);
    // проверка результата
    if (!ok) {
      setStatus(false);
      addError(sender.getErrors());
    } else {
      Message mimeMessage = sender.getMailMessage();
      if (mimeMessage != null) {
        // appendEmailToSent(mimeMessage);
      }
    }
  }