public with sharing class PersonalProcessInstanceController {
|
public List<ProcessInfo> accPIList { get; private set; }
|
public List<ProcessInfo> conPIList { get; private set; }
|
public List<ProcessInfo> oppPIList { get; private set; }
|
public List<ProcessInfo> odrPIList { get; private set; }
|
public List<ProcessInfo> othPIList { get; private set; }
|
|
private String userId;
|
|
public Integer getAccPIListSize() {
|
return accPIList.size();
|
}
|
|
public Integer getConPIListSize() {
|
return conPIList.size();
|
}
|
|
public Integer getOppPIListSize() {
|
return oppPIList.size();
|
}
|
|
public Integer getOdrPiListSize() {
|
return odrPIList.size();
|
}
|
|
public Integer getOthPIListSize() {
|
return othPIList.size();
|
}
|
|
public PersonalProcessInstanceController() {
|
userId = ApexPages.currentPage().getParameters().get('uid');
|
if (userId == null || userId == '') {
|
userId = UserInfo.getUserId();
|
}
|
}
|
|
public PageReference init() {
|
List<ProcessInstanceWorkitem> piwList = [select id, ActorId, CreatedDate, ElapsedTimeInDays, OriginalActorId,
|
ProcessInstance.TargetObjectId, ProcessInstance.Targetobject.Name, ProcessInstance.Status, ProcessInstance.SubmittedbyId, ProcessInstance.Submittedby.Name
|
from ProcessInstanceWorkitem
|
where ActorId = :userId
|
order by ProcessInstance.TargetobjectId, CreatedDate asc];
|
|
Integer lineNo = 0;
|
accPIList = new List<ProcessInfo>();
|
conPIList = new List<ProcessInfo>();
|
oppPIList = new List<ProcessInfo>();
|
odrPIList = new List<ProcessInfo>();
|
othPIList = new List<ProcessInfo>();
|
if (piwList.size() > 0) {
|
for (ProcessInstanceWorkitem piw : piwList) {
|
lineNo += 1;
|
String targetObjectId = piw.ProcessInstance.TargetObjectId;
|
if (targetObjectId.startsWith('001') == true) {
|
// account
|
ProcessInfo newpi = new ProcessInfo(lineNo, piw, 'account');
|
accPIList.add(newpi);
|
} else if (targetObjectId.startsWith('003') == true) {
|
// contact
|
ProcessInfo newpi = new ProcessInfo(lineNo, piw, 'contact');
|
conPIList.add(newpi);
|
} else if (targetObjectId.startsWith('006') == true) {
|
// opportunity
|
ProcessInfo newpi = new ProcessInfo(lineNo, piw, 'opportunity');
|
oppPIList.add(newpi);
|
} else if (targetObjectId.startsWith('801') == true) {
|
// order
|
ProcessInfo newpi = new ProcessInfo(lineNo, piw, 'order');
|
odrPIList.add(newpi);
|
} else {
|
// others
|
ProcessInfo newpi = new ProcessInfo(lineNo, piw, 'other');
|
othPIList.add(newpi);
|
}
|
}
|
}
|
|
return null;
|
}
|
|
class ProcessInfo {
|
public Integer lineNo { get; private set; }
|
public ProcessInstanceWorkitem piw { get; private set; }
|
public Decimal elapsedTimeInDays { get; private set; }
|
// accpunt,contact,opportunity,order,other
|
public String pType { get; private set; }
|
|
public ProcessInfo(Integer in_no, ProcessInstanceWorkitem in_piw, String in_pType) {
|
lineNo = in_no;
|
piw = in_piw;
|
pType = in_pType;
|
elapsedTimeInDays = in_piw.ElapsedTimeInDays;
|
elapsedTimeInDays = elapsedTimeInDays.setScale(1);
|
}
|
}
|
}
|