コード例 #1
0
 /**
  * Description of the Method
  *
  * @param context Description of the Parameter
  * @return Description of the Return Value
  */
 public String executeCommandModify(ActionContext context) {
   if (!(hasPermission(context, "tickets-tickets-tasks-edit"))) {
     return ("PermissionError");
   }
   Connection db = null;
   Task thisTask = null;
   String forward = context.getRequest().getParameter("forward");
   if (forward != null && !"".equals(forward.trim())) {
     context.getRequest().setAttribute("forward", forward);
   }
   String id = context.getRequest().getParameter("id");
   addModuleBean(context, "View Tickets", "Add Ticket");
   SystemStatus systemStatus = this.getSystemStatus(context);
   String ticketId = context.getRequest().getParameter("ticketId");
   Ticket thisTicket = null;
   try {
     db = this.getConnection(context);
     thisTask = (Task) context.getFormBean();
     if (thisTask.getId() == -1) {
       thisTask = new Task(db, Integer.parseInt(id));
     }
     // Load the ticket
     if (ticketId != null && !"".equals(ticketId)) {
       thisTicket = new Ticket(db, Integer.parseInt(ticketId));
     } else {
       thisTicket = new Ticket(db, thisTask.getTicketId());
     }
     // Check access permission to organization record
     if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
       return ("PermissionError");
     }
     thisTask.checkEnabledOwnerAccount(db);
     if (thisTask.getContactId() > -1) {
       thisTask.checkEnabledLinkAccount(db);
       Contact contact = new Contact(db, thisTask.getContactId());
       thisTask.setContactName(contact.getNameFull());
     }
     LookupList list = systemStatus.getLookupList(db, "lookup_ticket_task_category");
     list.addItem(-1, systemStatus.getLabel("calendar.none.4dashes", "-- None --"));
     context.getRequest().setAttribute("ticketTaskCategoryList", list);
   } catch (Exception e) {
     context.getRequest().setAttribute("Error", e);
     return ("SystemError");
   } finally {
     this.freeConnection(context, db);
   }
   context.getRequest().setAttribute("Task", thisTask);
   if (!hasAuthority(context, thisTask.getOwner())
       || !(hasPermission(context, "tickets-tickets-tasks-edit"))) {
     if (hasPermission(context, "tickets-tickets-tasks-view")) {
       return "TaskDetailsOK";
     }
     return ("PermissionError");
   }
   return "AddTaskOK";
 }
  /**
   * Description of the Method
   *
   * @param context Description of the Parameter
   * @return Description of the Return Value
   */
  public String executeCommandProjects(ActionContext context) {
    // Parameters
    String value = context.getRequest().getParameter("source");
    String search = context.getRequest().getParameter("search");
    StringTokenizer st = new StringTokenizer(value, "|");
    String source = st.nextToken();
    String status = st.nextToken();
    // Build the list
    Connection db = null;
    ProjectList projects = new ProjectList();
    try {
      db = getConnection(context);
      if ("my".equals(source) || "all".equals(source)) {
        projects.setProjectsForUser(getUserId(context));
        projects.setIncludeGuestProjects(false);
        if ("open".equals(status)) {
          // Check if open or closed
          projects.setOpenProjectsOnly(true);
        } else {
          projects.setClosedProjectsOnly(true);
        }
        projects.buildList(db);
        context.getRequest().setAttribute("projectList", projects);
        return "ProjectsOK";
      } else if ("dept".equals(source) && "all".equals(status)) {
        LookupList departmentList = new LookupList(db, "lookup_department");
        departmentList.addItem(0, "Without a department");
        context.getRequest().setAttribute("departments", departmentList);
        return "MakeDepartmentListOK";
      } else if ("acct".equals(source) && "all".equals(status)) {
        OrganizationList organizationList = new OrganizationList();
        organizationList.setName('%' + search + '%');
        organizationList.buildShortList(db);
        context.getRequest().setAttribute("orgList", organizationList);
        return "MakeOrgListOK";
      }
    } catch (Exception e) {

    } finally {
      freeConnection(context, db);
    }
    return null;
  }
コード例 #3
0
  /**
   * Description of the Method
   *
   * @param context Description of the Parameter
   * @return Description of the Return Value
   */
  public String executeCommandAdd(ActionContext context) {
    if (!hasPermission(context, "tickets-tickets-tasks-add")) {
      return ("PermissionError");
    }
    Connection db = null;

    try {
      db = this.getConnection(context);
      // Load the ticket
      Ticket thisTicket =
          new Ticket(db, Integer.parseInt(context.getRequest().getParameter("ticketId")));
      // Check access permission to organization record
      if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
        return ("PermissionError");
      }

      TicketTask thisTicketTask = (TicketTask) context.getFormBean();
      if (thisTicketTask.getEnteredBy() == -1) {
        thisTicketTask = new TicketTask();
        thisTicketTask.setTicketId(thisTicket.getId());
      }
      Task thisTask = thisTicketTask;
      context.getRequest().setAttribute("Task", thisTask);

      SystemStatus systemStatus = this.getSystemStatus(context);
      LookupList list = systemStatus.getLookupList(db, "lookup_ticket_task_category");
      list.addItem(-1, systemStatus.getLabel("calendar.none.4dashes", "-- None --"));
      context.getRequest().setAttribute("ticketTaskCategoryList", list);
    } catch (Exception e) {
      context.getRequest().setAttribute("Error", e);
      return ("SystemError");
    } finally {
      this.freeConnection(context, db);
    }

    addModuleBean(context, "View Tickets", "Add Ticket");
    return ("AddTaskOK");
  }
コード例 #4
0
  /**
   * Description of the Method
   *
   * @param context Description of the Parameter
   * @return Description of the Return Value
   */
  public String executeCommandSave(ActionContext context) {
    String permission = "tickets-tickets-tasks-edit";
    Connection db = null;
    int resultCount = -1;
    boolean recordInserted = false;
    boolean isValid = false;
    String addAnother = (String) context.getRequest().getParameter("addAnother");
    if (addAnother != null && !"".equals(addAnother.trim())) {
      context.getRequest().setAttribute("addAnother", addAnother);
    }
    String forward = context.getRequest().getParameter("forward");
    if (forward != null && !"".equals(forward.trim())) {
      context.getRequest().setAttribute("forward", forward);
    }
    String ticketId = context.getRequest().getParameter("ticketId");
    TicketTask thisTask = (TicketTask) context.getFormBean();
    SystemStatus systemStatus = this.getSystemStatus(context);
    String action = (thisTask.getId() > 0 ? "modify" : "insert");
    if ("insert".equals(action)) {
      permission = "tickets-tickets-tasks-add";
    }
    if (!hasPermission(context, permission)) {
      return ("PermissionError");
    }
    thisTask.setModifiedBy(getUserId(context));
    try {
      db = this.getConnection(context);
      if ("insert".equals(action)) {
        // Load the ticket
        Ticket thisTicket = new Ticket(db, Integer.parseInt(ticketId));
        // Check access permission to organization record
        if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) {
          return ("PermissionError");
        }
        if (forward != null || addAnother != null) {
          LookupList list = systemStatus.getLookupList(db, "lookup_ticket_task_category");
          list.addItem(-1, systemStatus.getLabel("calendar.none.4dashes", "-- None --"));
          context.getRequest().setAttribute("ticketTaskCategoryList", list);
        }
        thisTask.setEnteredBy(getUserId(context));
        thisTask.setTicketId(Integer.parseInt(ticketId));
        isValid = this.validateObject(context, db, thisTask);
        if (isValid) {
          recordInserted = thisTask.insert(db);
        }
        if (recordInserted) {
          this.processInsertHook(context, thisTask);
        }
      } else {
        Task oldTask = new Task(db, thisTask.getId());
        if (!hasAuthority(context, oldTask.getOwner())) {
          return ("PermissionError");
        }
        isValid = this.validateObject(context, db, thisTask);
        if (isValid) {
          resultCount = thisTask.update(db);
        }
        if (resultCount == 1) {
          this.processUpdateHook(context, oldTask, thisTask);
        }
      }
      if (!isValid || !(recordInserted || resultCount == 1)) {
        if (thisTask.getContactId() > -1) {
          thisTask.checkEnabledLinkAccount(db);
          Contact contact = new Contact(db, thisTask.getContactId());
          thisTask.setContactName(contact.getNameFull());
          context.getRequest().setAttribute("Task", thisTask);
        }
      }
    } catch (Exception e) {
      context.getRequest().setAttribute("Error", e);
      return ("SystemError");
    } finally {
      this.freeConnection(context, db);
    }
    if (recordInserted || resultCount == 1) {
      if ((resultCount == 1 || recordInserted)
          && forward != null
          && "details".equals(forward.trim())) {
        context.getRequest().setAttribute("id", String.valueOf(thisTask.getId()));
        context.getRequest().setAttribute("forward", forward);
        return executeCommandDetails(context);
      }
      if (recordInserted && addAnother != null && "true".equals(addAnother.trim())) {
        Task task = new Task();
        task.setTicketId(ticketId);
        context.getRequest().setAttribute("Task", task);
        return "AddTaskOK";
      }

      addModuleBean(context, "View Tickets", "Ticket Save OK");
      return ("SaveOK");
    }
    if ("insert".equals(action)) {
      return executeCommandAdd(context);
    } else {
      return executeCommandModify(context);
    }
  }
コード例 #5
0
  /**
   * Description of the Method
   *
   * @param context Description of the Parameter
   * @return Description of the Return Value
   */
  public String executeCommandDetails(ActionContext context) {
    if (!(hasPermission(context, "sales-leads-action-plans-view"))) {
      return ("PermissionError");
    }
    Exception errorMessage = null;
    Connection db = null;
    Contact ContactDetails = null;
    try {
      db = this.getConnection(context);

      String contactId = context.getRequest().getParameter("contactId");
      if (contactId == null) {
        contactId = (String) context.getRequest().getAttribute("contactId");
      }
      ContactDetails = new Contact(db, Integer.parseInt(contactId));
      if (!isRecordAccessPermitted(context, ContactDetails)) {
        return ("PermissionError");
      }
      context.getRequest().setAttribute("ContactDetails", ContactDetails);

      String actionPlanId = context.getRequest().getParameter("actionPlanId");
      if (actionPlanId == null || "".equals(actionPlanId)) {
        actionPlanId = (String) context.getRequest().getAttribute("actionPlanId");
      }
      ActionPlanWork planWork = new ActionPlanWork();
      planWork.setBuildPhaseWork(true);
      planWork.setBuildGlobalPhases(Constants.FALSE);
      planWork.setBuildStepWork(true);
      planWork.setBuildLinkedObject(true);
      planWork.queryRecord(db, Integer.parseInt(actionPlanId));
      planWork.buildStepLinks();
      context.getRequest().setAttribute("actionPlanWork", planWork);

      // Build plan with just the global phases
      ActionPlanWork globalPlanWork = new ActionPlanWork();
      globalPlanWork.setBuildPhaseWork(true);
      globalPlanWork.setBuildGlobalPhases(Constants.TRUE);
      globalPlanWork.setBuildStepWork(true);
      globalPlanWork.setBuildLinkedObject(true);
      globalPlanWork.queryRecord(db, Integer.parseInt(actionPlanId));
      context.getRequest().setAttribute("globalActionPlanWork", globalPlanWork);

      SystemStatus thisSystem = this.getSystemStatus(context);
      LookupList ratingLookup = thisSystem.getLookupList(db, "lookup_contact_rating");
      ratingLookup.addItem(-1, thisSystem.getLabel("calendar.none.4dashes"));
      ratingLookup.setJsEvent("onChange=\"javascript:updateRating(this);\"");
      context.getRequest().setAttribute("ratingLookup", ratingLookup);
      context.getRequest().setAttribute("systemStatus", thisSystem);
      context
          .getRequest()
          .setAttribute(
              "objectName", ActionPlan.getDescriptionGivenConstantId(db, ActionPlan.LEADS));
      context.getRequest().setAttribute("constants", ActionPlan.buildConstants(db));
      String notAttached = context.getRequest().getParameter("notAttached");

      Organization orgDetails = new Organization();
      context.getRequest().setAttribute("orgDetails", orgDetails);

      if (notAttached != null && "true".equals(notAttached.trim())) {
        context
            .getRequest()
            .setAttribute(
                "actionWarning",
                thisSystem.getLabel("", "The recipient was not added to the active campaign"));
      }
    } catch (Exception e) {
      e.printStackTrace();
      context.getRequest().setAttribute("Error", e);
      return ("SystemError");
    } finally {
      this.freeConnection(context, db);
    }
    return getReturn(context, "Details");
  }