Re: svn commit: r703081 - in /ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr: WEB-INF/actions/GanttChart.groovy project/gantChart.ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r703081 - in /ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr: WEB-INF/actions/GanttChart.groovy project/gantChart.ftl

Adrian Crum
Hans,

It is better to use the UtilDateTime.adjustTimestamp(...) method instead
of UtilDateTime.addDaysToTimestamp(...). The
UtilDateTime.addDaysToTimestamp method will give unpredictable results.

-Adrian

[hidden email] wrote:

> Author: hansbak
> Date: Thu Oct  9 00:17:09 2008
> New Revision: 703081
>
> URL: http://svn.apache.org/viewvc?rev=703081&view=rev
> Log:
> some more improvements to the ganttchart....nor perfect yet however improoving
>
> Modified:
>     ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/GanttChart.groovy
>     ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/project/gantChart.ftl
>
> Modified: ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/GanttChart.groovy
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/GanttChart.groovy?rev=703081&r1=703080&r2=703081&view=diff
> ==============================================================================
> --- ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/GanttChart.groovy (original)
> +++ ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/GanttChart.groovy Thu Oct  9 00:17:09 2008
> @@ -22,24 +22,71 @@
>  import org.ofbiz.entity.*;
>  import org.ofbiz.base.util.*;
>  import org.ofbiz.entity.util.*;
> -import org.ofbiz.base.util.*;
>  
>  projectId = parameters.projectId;
>  userLogin = parameters.userLogin;
>  
> +//project info
> +result = dispatcher.runSync("getProject", [projectId : projectId, userLogin : userLogin]);
> +project = result.projectInfo;
> +if (project && project.startDate)
> +    context.chartStart = project.startDate;
> +else
> +    context.chartStart = UtilDateTime.nowTimestamp(); // default todays date
> +if (project && project.completionDate)        
> +    context.chartEnd = project.completionDate;
> +else
> +    context.chartEnd = UtilDateTime.addDaysToTimestamp(UtilDateTime.nowTimestamp(), 14); // default 14 days long
> +
> +if (project == null) return;
> +
>  ganttList = new LinkedList();
>  result = dispatcher.runSync("getProjectPhaseList", [userLogin : userLogin , projectId : projectId]);
> -phases = result.get("phaseList");
> +phases = result.phaseList;
>  if (phases){
>   phases.each { phase ->
> + newPhase = phase;
> +        if (!newPhase.estimatedStartDate && newPhase.actualStartDate) {
> +            newPhase.estimatedStartDate = newPhase.actualStartDate;
> +        }
> +        if (!newPhase.estimatedStartDate) {
> +            newPhase.estimatedStartDate = context.chartStart;
> +        }
> +        if (!newPhase.estimatedCompletionDate && newPhase.actualCompletionDate) {
> +            newPhase.estimatedCompletionDate = newPhase.actualCompletionDateDate;
> +        }
> +        if (!newPhase.estimatedCompletionDate) {
> +            newPhase.estimatedCompletionDate = UtilDateTime.addDaysToTimestamp(newPhase.estimatedStartDate, 3);
> +        }
> +        newPhase.workEffortTypeId = "PHASE";
> +        Debug.log("===start: " + newPhase.estimatedStartDate + "===end: " + newPhase.estimatedCompletionDate);
> + ganttList.add(newPhase);
> + Debug.log("=======" + phase.phaseName + "======" + phase.workEffortTypeId + " phaseId" + phase.phaseId);
>   tasks = delegator.findByAnd("WorkEffort", ["workEffortParentId" : phase.phaseId]);
>   if (tasks){
>   tasks.each { task ->
> - ganttList.add(task);
> +        Debug.log("===name====" + task.workEffortName + "===type===" + task.workEffortTypeId + "===id===" + task.workEffortId);
> +         resultTaskInfo = dispatcher.runSync("getProjectTask", [userLogin : userLogin , taskId : task.workEffortId]);
> +                Debug.log("===restaskinfo " + resultTaskInfo);
> +         taskInfo = resultTaskInfo.taskInfo;
> +         Debug.log("===taskinfo " + taskInfo);
> +                if (!taskInfo.estimatedStartDate && taskInfo.actualStartDate) {
> +                    taskInfo.estimatedStartDate = taskInfo.actualStartDate;
> +                }
> +                if (!taskInfo.estimatedStartDate) {
> +                    taskInfo.estimatedStartDate = newPhase.estimatedStartDate;
> +                }
> +                if (!taskInfo.estimatedCompletionDate && taskInfo.actualCompletionDate) {
> +                    taskInfo.estimatedCompletionDate = taskInfo.actualCompletionDate;
> +                }
> +                if (!taskInfo.estimatedCompletionDate) {
> +                    taskInfo.estimatedCompletionDate = UtilDateTime.addDaysToTimestamp(newPhase.estimatedStartDate, 3);
> +                }
> +                taskInfo.workEffortTypeId = "TASK";
> + ganttList.add(taskInfo);
>   }
>   }
>   }
>  }
> -context.phases = phases;
> -context.tasks = ganttList;
> +context.phaseTaskList = ganttList;
>  
>
> Modified: ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/project/gantChart.ftl
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/project/gantChart.ftl?rev=703081&r1=703080&r2=703081&view=diff
> ==============================================================================
> --- ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/project/gantChart.ftl (original)
> +++ ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/project/gantChart.ftl Thu Oct  9 00:17:09 2008
> @@ -22,8 +22,9 @@
>  <#assign phasesummary2 = 0/>
>  <#assign summary2 = 0/>
>  <#assign day = 24 * 60 * 60 * 1000/>
> -<#if phases?has_content>
> -<#list phases as phases>
> +<#if phaseTaskList?has_content>
> +<#list phaseTaskList as phases>
> +<#if phases.workEffortTypeId == "PHASE">
>   <#assign phaseId = phases.phaseId/>
>   <#assign phasesStart = Static["org.ofbiz.base.util.UtilDateTime"].toCalendar(phases.estimatedStartDate)/>
>   <#assign phasesEnd = Static["org.ofbiz.base.util.UtilDateTime"].toCalendar(phases.estimatedCompletionDate)/>
> @@ -57,13 +58,14 @@
>   <img src="/images/busy.gif" height="15px;" width="${phasesummary2}px;">
>   </td>
>   </tr>
> - </#if>
> - <#if tasks?has_content>
> - <#list tasks as tasks>
> +    </#if>      
> +</#if>
> +<#if phases.workEffortTypeId == "TASK">
> +    <#assign tasks = phases/>      
>   <#assign phasesId = tasks.workEffortParentId/>
> - <#assign taskId = tasks.workEffortId/>
> - <#assign taskStart = Static["org.ofbiz.base.util.UtilDateTime"].toCalendar(tasks.estimatedStartDate)/>
> - <#assign taskEnd = Static["org.ofbiz.base.util.UtilDateTime"].toCalendar(tasks.estimatedCompletionDate)/>
> + <#assign taskId = tasks.taskId/>
> + <#assign taskStart = Static["org.ofbiz.base.util.UtilDateTime"].toCalendar(tasks.estimatedStartDate?if_exists)/>
> + <#assign taskEnd = Static["org.ofbiz.base.util.UtilDateTime"].toCalendar(tasks.estimatedCompletionDate?if_exists)/>
>   <#assign t3 = taskStart.getTime().getTime()/>
>   <#assign t4 = taskEnd.getTime().getTime()/>
>   <#assign startMonth = tasks.estimatedStartDate?substring(5,7)?number/>
> @@ -79,7 +81,7 @@
>   <#assign spacer2 = 732 - (spacer + summary)/>
>   <tr>
>   <td style="width: 150px; vertical-align: bottom;" >
> - <a href="/projectmgr/control/taskView?workEffortId=${tasks.workEffortId}">${tasks.workEffortName?if_exists}</a>
> + <a href="/projectmgr/control/taskView?workEffortId=${tasks.taskId}">${tasks.taskName?if_exists}</a>
>   </td>
>   <td  colspan="12">
>   <img src="/images/spacer.gif" height="15px;" width="${spacer}px;"><img src="/images/bluebar.gif" height="15px;" width="${summary}px;"><img src="/images/spacer.gif" height="15px;" width="${spacer2}px;">
> @@ -96,8 +98,7 @@
>   </tr>
>   </#if>
>   </#if>
> - </#list>
> - </#if>
> +</#if>  
>  </#list>
>  </#if>
>  </table>
>
>
>