Author: hansbak
Date: Sun Nov 2 14:45:11 2008 New Revision: 709976 URL: http://svn.apache.org/viewvc?rev=709976&view=rev Log: upgrade of jsgantt, the developer Shlomy Gantz fixed an error for me, thanks! Further the scheduler is improoved Modified: ofbiz/trunk/framework/images/webapp/images/jsgantt.js ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/actions/GanttChart.groovy ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/project/gantChart.ftl Modified: ofbiz/trunk/framework/images/webapp/images/jsgantt.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/jsgantt.js?rev=709976&r1=709975&r2=709976&view=diff ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/jsgantt.js (original) +++ ofbiz/trunk/framework/images/webapp/images/jsgantt.js Sun Nov 2 14:45:11 2008 @@ -94,35 +94,28 @@ Graphics.prototype.createPlotElement = function(x,y,w,h) { // detect canvas -// if ( !this.oCanvas ) -// { - if ( (this.canvas == undefined) || (this.canvas == "") ) - this.oCanvas = document.body; - else - this.oCanvas = document.getElementById(this.canvas); -// } + if ( (this.canvas == undefined) || (this.canvas == "") ) + this.oCanvas = document.body; + else + this.oCanvas = document.getElementById(this.canvas); // retrieve DIV var oDiv; -// if ( this.cache.length ) { -// oDiv = this.cache.pop(); -// } else { - oDiv = document.createElement('div'); - this.oCanvas.appendChild(oDiv); - - oDiv.style.position = "absolute"; - oDiv.style.margin = "0px"; - oDiv.style.padding = "0px"; - oDiv.style.overflow = "hidden"; - oDiv.style.border = "0px"; -// } + oDiv = document.createElement('div'); + this.oCanvas.appendChild(oDiv); + + oDiv.style.position = "absolute"; + oDiv.style.margin = "0px"; + oDiv.style.padding = "0px"; + oDiv.style.overflow = "hidden"; + oDiv.style.border = "0px"; // set attributes oDiv.style.zIndex = this.zIndex; oDiv.style.backgroundColor = this.penColor; - oDiv.style.left = x; - oDiv.style.top = y; + oDiv.style.left = x + "px"; + oDiv.style.top = y + "px"; oDiv.style.width = w + "px"; oDiv.style.height = h + "px"; @@ -916,9 +909,9 @@ ' <TD style="BORDER-TOP: #efefef 1px solid; WIDTH: ' + vNameWidth + 'px; HEIGHT: 20px"><NOBR></NOBR></TD>' ; - if(vShowRes ==1) vLeftTable += ' <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=middle nowrap>Resource</TD>' ; - if(vShowDur ==1) vLeftTable += ' <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=middle nowrap>Duration</TD>' ; - if(vShowComp==1) vLeftTable += ' <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=middle nowrap>% Comp.</TD>' ; + if(vShowRes ==1) vLeftTable += ' <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=center nowrap>Resource</TD>' ; + if(vShowDur ==1) vLeftTable += ' <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=center nowrap>Duration</TD>' ; + if(vShowComp==1) vLeftTable += ' <TD style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 60px; HEIGHT: 20px" align=center nowrap>% Comp.</TD>' ; vLeftTable += '</TR>'; @@ -973,11 +966,11 @@ '<span onclick=JSGantt.taskLink("' + vTaskList[i].getLink() + '",300,200); style="cursor:pointer"> ' + vTaskList[i].getName() + '</span></NOBR></TD>' ; - if(vShowRes ==1) vLeftTable += ' <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=middle><NOBR>' + vTaskList[i].getResource() + '</NOBR></TD>' ; + if(vShowRes ==1) vLeftTable += ' <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><NOBR>' + vTaskList[i].getResource() + '</NOBR></TD>' ; - if(vShowDur ==1) vLeftTable += ' <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=middle><NOBR>' + vTaskList[i].getDuration(vFormat) + '</NOBR></TD>' ; + if(vShowDur ==1) vLeftTable += ' <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><NOBR>' + vTaskList[i].getDuration(vFormat) + '</NOBR></TD>' ; - if(vShowComp==1) vLeftTable += ' <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=middle><NOBR>' + vTaskList[i].getCompStr() + '</NOBR></TD>' ; + if(vShowComp==1) vLeftTable += ' <TD class=gname style="WIDTH: 60px; HEIGHT: 20px; TEXT-ALIGN: center; BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><NOBR>' + vTaskList[i].getCompStr() + '</NOBR></TD>' ; vLeftTable += '</TR>'; @@ -1077,7 +1070,7 @@ { - vRightTable += '<td class=gdatehead align=center style="FONT-SIZE: 12px; HEIGHT: 19px;" width='+vColWidth+'>`'+ vStr + '</td>'; + vRightTable += '<td class=gdatehead align=center style="FONT-SIZE: 12px; HEIGHT: 19px;" width='+vColWidth+'px>`'+ vStr + '</td>'; vTmpDate.setDate(vTmpDate.getDate()+7); @@ -1087,7 +1080,7 @@ { - vRightTable += '<td class=gdatehead align=center style="FONT-SIZE: 12px; HEIGHT: 19px;" width='+vColWidth+'>`'+ vStr + '</td>'; + vRightTable += '<td class=gdatehead align=center style="FONT-SIZE: 12px; HEIGHT: 19px;" width='+vColWidth+'px>`'+ vStr + '</td>'; vTmpDate.setDate(vTmpDate.getDate() + 1); @@ -1137,17 +1130,17 @@ if(vTmpDate.getDay() % 6 == 0) { - vDateRowStr += '<td class="gheadwkend" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" bgcolor=#cfcfcf align=middle><div style="width: '+vColWidth+'">' + vTmpDate.getDate() + '</div></td>'; + vDateRowStr += '<td class="gheadwkend" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" bgcolor=#cfcfcf align=center><div style="width: '+vColWidth+'px">' + vTmpDate.getDate() + '</div></td>'; - vItemRowStr += '<td class="gheadwkend" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; cursor: default;" bgcolor=#cfcfcf align=middle><div style="width: '+vColWidth+'"> </div></td>'; + vItemRowStr += '<td class="gheadwkend" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; cursor: default;" bgcolor=#cfcfcf align=center><div style="width: '+vColWidth+'px"> </div></td>'; } else { - vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" align=middle><div style="width: '+vColWidth+'">' + vTmpDate.getDate() + '</div></td>'; + vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">' + vTmpDate.getDate() + '</div></td>'; - vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; cursor: default;" align=middle><div style="width: '+vColWidth+'">  </div></td>'; + vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; cursor: default;" align=center><div style="width: '+vColWidth+'px">  </div></td>'; } @@ -1171,15 +1164,15 @@ if(vNxtDate <= vMaxDate) { - vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" align=middle width:'+vColWidth+'><div style="width: '+vColWidth+'">' + (vTmpDate.getMonth()+1) + '/' + vTmpDate.getDate() + '</div></td>'; + vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">' + (vTmpDate.getMonth()+1) + '/' + vTmpDate.getDate() + '</div></td>'; - vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=middle><div style="width: '+vColWidth+'">  </div></td>'; + vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">  </div></td>'; } else { - vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=middle width:'+vColWidth+'><div style="width: '+vColWidth+'">' + (vTmpDate.getMonth()+1) + '/' + vTmpDate.getDate() + '</div></td>'; + vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">' + (vTmpDate.getMonth()+1) + '/' + vTmpDate.getDate() + '</div></td>'; - vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=middle><div style="width: '+vColWidth+'">  </div></td>'; + vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">  </div></td>'; } @@ -1203,15 +1196,15 @@ if(vNxtDate <= vMaxDate) { - vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" align=middle width:'+vColWidth+'><div style="width: '+vColWidth+'">' + month[vTmpDate.getMonth()].substr(0,3) + '</div></td>'; + vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid;" align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">' + month[vTmpDate.getMonth()].substr(0,3) + '</div></td>'; - vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=middle><div style="width: '+vColWidth+'">  </div></td>'; + vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">  </div></td>'; } else { - vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=middle width:'+vColWidth+'><div style="width: '+vColWidth+'">' + month[vTmpDate.getMonth()].substr(0,3) + '</div></td>'; + vDateRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; HEIGHT: 19px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=center width:'+vColWidth+'px><div style="width: '+vColWidth+'px">' + month[vTmpDate.getMonth()].substr(0,3) + '</div></td>'; - vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=middle><div style="width: '+vColWidth+'">  </div></td>'; + vItemRowStr += '<td class="ghead" style="BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; BORDER-RIGHT: #efefef 1px solid;" align=center><div style="width: '+vColWidth+'px">  </div></td>'; } @@ -1248,7 +1241,6 @@ - // Draw each row for(i = 0; i < vTaskList.length; i++) @@ -1400,7 +1392,7 @@ '<div id=bardiv_' + vID + ' style="position:absolute; top:4px; left:' + Math.ceil(vTaskLeft * (vDayWidth) + 1) + 'px; width:' + Math.ceil((vTaskRight) * (vDayWidth) - 1) + 'px">' + - '<div id=taskbar_' + vID + ' title="' + vTaskList[i].getName() + ': ' + vDateRowStr + '" class=gtask style="background-color:' + vTaskList[i].getColor() +'; height: 13px; width:' + Math.ceil((vTaskRight) * (vDayWidth) - 1) + 'px; cursor: pointer;" ' + + '<div id=taskbar_' + vID + ' title="' + vTaskList[i].getName() + ': ' + vDateRowStr + '" class=gtask style="background-color:#' + vTaskList[i].getColor() +'; height: 13px; width:' + Math.ceil((vTaskRight) * (vDayWidth) - 1) + 'px; cursor: pointer;" ' + 'onclick=JSGantt.taskLink("' + vTaskList[i].getLink() + '",300,200);>' + Modified: ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml?rev=709976&r1=709975&r2=709976&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml (original) +++ ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml Sun Nov 2 14:45:11 2008 @@ -177,12 +177,20 @@ --> <field-to-result map-name="parameters" field-name="projectId"/> + <!-- find a starting point being either the estimated start date of a project or the earliest actual start date. --> <entity-condition entity-name="ProjectAndPhaseAndTask" list-name="tasks"> <condition-expr field-name="actualStartDate" operator="not-equals" env-name="null"/> <order-by field-name="-actualStartDate"/> </entity-condition> + <if-not-empty field="tasks"> + <!-- remove all estimated dates --> + <iterate entry-name="task" list-name="tasks"> + <clear-field field-name="task.estimatedStartDate"/> + <clear-field field-name="task.estimatedCompletionDate"/> + </iterate> + <first-from-list entry-name="task" list-name="tasks"/> <set field="startDate" from-field="task.actualStartDate"/> <set field="taskId" from-field="task.workEffortId"/> Modified: ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java?rev=709976&r1=709975&r2=709976&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java (original) +++ ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java Sun Nov 2 14:45:11 2008 @@ -47,9 +47,12 @@ while (a.hasNext()) { GenericValue assoc = (GenericValue) a.next(); GenericValue nextTask = assoc.getRelatedOne("ToWorkEffort"); - nextTask.put("estimatedStartDate", UtilDateTime.addDaysToTimestamp(task.getTimestamp("estimatedCompletionDate"), 1)); // start of next task the next day - nextTask.put("estimatedCompletionDate", calculateCompletionDate(nextTask, task.getTimestamp("estimatedCompletionDate"))); - nextTask.store(); + Timestamp newStartDate = task.getTimestamp("estimatedCompletionDate"); // start of next task the next day + if (nextTask.get("estimatedStartDate") == null || nextTask.getTimestamp("estimatedStartDate").before(newStartDate) ) { + nextTask.put("estimatedStartDate", UtilDateTime.addDaysToTimestamp(task.getTimestamp("estimatedCompletionDate"), 1)); // start of next task the next day + nextTask.put("estimatedCompletionDate", calculateCompletionDate(nextTask, task.getTimestamp("estimatedCompletionDate"))); + nextTask.store(); + } setDatesFollowingTasks(nextTask); } } 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=709976&r1=709975&r2=709976&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 Sun Nov 2 14:45:11 2008 @@ -77,7 +77,7 @@ double duration = resultTaskInfo.plannedHours; if (taskInfo.currentStatusId == "PTS_COMPLETED") { taskInfo.completion = 100; - }else{ + } else { if (taskInfo.actualHours) { taskInfo.completion = new BigDecimal(taskInfo.actualHours*100/taskInfo.plannedHours).setScale(0, BigDecimal.ROUND_UP); } else { @@ -107,10 +107,21 @@ taskInfo.url = ""; } - // dependency + // dependency can only show one in the ganttchart, so onl show the latest one.. preTasks = delegator.findByAnd("WorkEffortAssoc", ["workEffortIdTo" : task.workEffortId], ["workEffortIdFrom"]); - if (preTasks) { - taskInfo.preDecessor = preTasks[0].workEffortIdFrom; + latestTaskId = ""; + Timestamp latestDate = null; + preTasks.each { preTask -> + wf = preTask.getRelatedOne("FromWorkEffort"); + if (wf.estimatedStartDate) { + if (!latestDate || latestDate.before(wf.estimatedStartDate)) { + latestTaskId = wf.workEffortId; + latestDate = wf.estimatedStartDate; + } + } + } + if (latestDate) { + taskInfo.preDecessor = latestTaskId; } ganttList.add(taskInfo); } 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=709976&r1=709975&r2=709976&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/project/gantChart.ftl (original) +++ ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/project/gantChart.ftl Sun Nov 2 14:45:11 2008 @@ -30,10 +30,10 @@ <#list phaseTaskList as t> <#if t.workEffortTypeId == "PHASE"> - g.AddTaskItem(new JSGantt.TaskItem(${t.phaseNr}, "${t.phaseName}", "", "", "#00ff00", "", 0, "", 0, 1, 0, 1)); + g.AddTaskItem(new JSGantt.TaskItem(${t.phaseNr}, "${t.phaseName}", "", "", "00ff00", "", 0, "", 0, 1, 0, 1)); </#if> <#if t.workEffortTypeId == "TASK"> - g.AddTaskItem(new JSGantt.TaskItem(${t.taskNr},"${t.taskName}","${t.estimatedStartDate}", "${t.estimatedCompletionDate}","#009900", "${t.url}", 0 , "${t.resource?if_exists}", ${t.completion?if_exists} , 0, ${t.phaseNr}, 1<#if t.preDecessor?exists>, ${t.preDecessor}</#if>)); + g.AddTaskItem(new JSGantt.TaskItem(${t.taskNr},"${t.taskName}","${t.estimatedStartDate}", "${t.estimatedCompletionDate}","009900", "${t.url}", 0 , "${t.resource?if_exists}", ${t.completion?if_exists} , 0, ${t.phaseNr}, 1<#if t.preDecessor?exists>, ${t.preDecessor}</#if>)); </#if> </#list> @@ -52,6 +52,7 @@ pGroup: (optional) indicates whether this is a group(parent) - 0=NOT Parent; 1=IS Parent pParent: (required) identifies a parent pID, this causes this task to be a child of identified task pOpen: UNUSED - in future can be initially set to close folder when chart is first drawn +pDepend: dependency: need previous task finished. --> g.Draw(); |
Free forum by Nabble | Edit this page |