for(int d=1; d<start; d++){
sb.append("<td bgcolor=white></td>");
}
GanttChartUtil ganttChartUtil = new GanttChartUtil();
String chartBar = ganttChartUtil.getGanttChartBarHtml(start,drawingEnd, end, dueDate, status);
sb.append(chartBar);
if(drawingEnd<365) {
for(int d=drawingEnd+1; d<=365; d++){
sb.append("<td bgcolor=white></td>");
}
}
sb.append("</tr>");
}else{
String userName = ganttDao.getResName();
if(oldResName.equals(""+userName)){
userName = "";
}else{
oldResName = ""+userName;
sb.append("<tr class='gantable'>");
sb.append(" <td colspan='365' bgcolor='#FFFFFF' style='padding-left:5px; height:30px;'><span class='sectiontitle' >");
sb.append(" ");
sb.append(" </td>");
sb.append("</tr>");
}
sb.append("<tr class='gantable'>");
for(int d=1; d<start; d++){
sb.append("<td bgcolor=white></td>");
}
GanttChartUtil ganttChartUtil = new GanttChartUtil();
String chartBar = ganttChartUtil.getGanttChartBarHtml(start,drawingEnd, end, dueDate, status);
sb.append(chartBar);
if(drawingEnd<365) {
for(int d=drawingEnd+1; d<=365; d++){
sb.append("<td bgcolor=white></td>");
}
}
sb.append("</tr>");
}
}
} //end while
sb.append("</table>");
}else if(viewMode.equals(VIEW_TYPE_MONTH)){
rowCount = 0;
firstRowCount = (currentPage == 1) ? 0 : (currentPage-1) * intPageCnt + 1;
lastRowCount = (currentPage * intPageCnt);
int curMonth=today.getTime().getMonth()+1;
sb.append("<table style='table-layout:fixed;' bgcolor='#C7D3E4' border='0' cellspacing='0' cellpadding='0' WIDTH='100%' align='left' >");
sb.append(" <tr style='border:1px solid #C7D3E4; background:url(../images/Common/tabletitle.gif) repeat-x;height:30px;color:#29384a;font-weight:bold;font-size:11px;'>");
int tempCount=0;
for(int i=1; i<=12; i++){
tempCount++;
sb.append("<td style='border:1px solid #C7D3E4;' valign='top'>");
if(tempCount==curMonth) {
sb.append(" <div style='position:relative; width:100%'><div id='curBarDiv' style='position:absolute;width:100%;height:10;z-index:2;filter:alpha(opacity=50);background-color:#F2E3BD;opacity:0.5;'></div><div>");
}
sb.append("<div style='position:relative; width:100%' align='center'><font size='-2'>"+i+"M</font><div>");
sb.append("</td>");
}
sb.append("</tr>");
while(ganttDao.next()){
rowCount++;
if (rowCount >= firstRowCount && rowCount <= lastRowCount) {
String startdate=(ganttDao.getStartDate()).toString().substring(0,10);
String enddate=(ganttDao.getEndDate()).toString().substring(0,10);
String duedate=(ganttDao.getDueDate()).toString().substring(0,10);
int startMonth=1;
int startday=1;
int endMonth=1;
int endday=1;
int dueMonth=1;
int dueday=1;
if(ganttDao.getStartDate()!=null){
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(ganttDao.getStartDate());
startdate=(ganttDao.getStartDate()).toString();
//System.out.println(startdate);
if(startCalendar.before(firstDate)){
startMonth = 1;
startday=(100-(100/31))/10;
}else{
startMonth=Integer.parseInt(startdate.substring(5,7));
startday=(100-(Integer.parseInt(startdate.substring(8,10))*(100/31)))/10;
}
}else{
startMonth=now.get(Calendar.MONTH)+1;
startday =now.get(Calendar.DAY_OF_MONTH);
}
if(ganttDao.getEndDate()!=null){
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(ganttDao.getEndDate());
if(endCalendar.before(firstDate)){
endMonth = 1;
endday = (100-(100/31))/10;
}else{
endMonth=Integer.parseInt(enddate.substring(5,7));
endday=(Integer.parseInt(enddate.substring(8,10))*(100/31))/10;
}
}else{
startMonth=now.get(Calendar.MONTH)+1;
startday =now.get(Calendar.DAY_OF_MONTH);
}
if(ganttDao.getDueDate()!=null){
Calendar dueDateCalendar = Calendar.getInstance();
dueDateCalendar.setTime(ganttDao.getDueDate());
if(dueDateCalendar.before(firstDate)){
dueMonth = 0;
dueday = 0;
}else if(dueDateCalendar.after(lastDate)){
dueMonth = 12;//implicitly make it out of bound
dueday = 31;
}else{
dueMonth=Integer.parseInt(duedate.substring(5,7));
dueday=(Integer.parseInt(duedate.substring(8,10))*(100/31))/10;
}
}else{
dueMonth=endMonth;
dueday=endday;
}
int drawEndMonth=dueMonth>endMonth?dueMonth:endMonth;
//System.out.println(startMonth+" "+startday+" "+endMonth+" "+endday);
float start=(float)(startMonth*10+startday)/10;
float end=(float)(endMonth*10+endday)/10;;
float dueDate=(float)(dueMonth*10+dueday)/10;
float drawingEnd=(float)dueDate>end?dueDate:end;
//System.out.println(start+" "+end);
String status=ganttDao.getStatus();
if(!ganttDao.getStatus().equals("COMPLETED") && dueDate < end){
status="DELAY";
}
String processInstanceLabel;
if(orderby.equals("instance")){
if(oldProcessInstance.equals(""+ganttDao.getInstId())){
processInstanceLabel = "";
}else{
processInstanceLabel = ganttDao.get("name") + " ("+ganttDao.getInstId()+")";
oldProcessInstance = ""+ganttDao.getInstId();
if(rowCount>1){
sb.append("<tr><td height='15px' colspan='12' bgcolor='#FFFFFF' style='border:none;'></td></tr>");
}
sb.append("<tr class='gantable'>");
sb.append(" <td colspan='12' bgcolor='#FFFFFF' style='padding-left:5px; height:30px;'><span class='sectiontitle' >");
sb.append(" ");
sb.append(" </td>");
sb.append("</tr>");
}
String userName = ganttDao.getResName();
sb.append("<tr class='gantable'>");
for(int j=1; j<startMonth; j++){
sb.append("<td bgcolor=white></td>");
}
GanttChartUtil ganttChartUtil = new GanttChartUtil(now,"white","month");
String chartBar = ganttChartUtil.getGanttChartBarHtml(start,drawingEnd, end, dueDate, status);
sb.append(chartBar);
for(int j=drawEndMonth+1; j<=12; j++){
sb.append("<td bgcolor=white></td>");
}
sb.append("</tr>");
}else{
String userName = ganttDao.getResName();
if(oldResName.equals(""+userName)){
userName = "";
}else{
oldResName = ""+userName;
if(rowCount>1){
sb.append("<tr><td height='15px' colspan='365' bgcolor='#FFFFFF' style='border:none;'></td></tr>");
}
sb.append("<tr class='gantable'>");
sb.append(" <td colspan='"+12+"' bgcolor='#FFFFFF' style='padding-left:5px; height:30px;'><span class='sectiontitle' >");
sb.append(" ");
sb.append(" </td>");
sb.append("</tr>");
}
sb.append("<tr class='gantable'>");
for(int j=1; j<startMonth; j++){
sb.append("<td bgcolor=white></td>");
}
GanttChartUtil ganttChartUtil = new GanttChartUtil(now,"white","month");
String chartBar = ganttChartUtil.getGanttChartBarHtml(start,drawingEnd, end, dueDate, status);
sb.append(chartBar);
for(int j=drawEndMonth+1; j<=12; j++){
sb.append("<td bgcolor=white></td>");
}
sb.append("</tr>");
}
}
}
sb.append("</table>");
}else{
rowCount = 0;
firstRowCount = (currentPage == 1) ? 0 : (currentPage-1) * intPageCnt + 1;
lastRowCount = (currentPage * intPageCnt);
Vector weekInfo=new Vector();
String FIRST_DATE = Integer.toString( firstDate.get(Calendar.YEAR) );
FIRST_DATE += "-";
FIRST_DATE += "01";
FIRST_DATE += "-";
FIRST_DATE += "01";
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date = df.parse(FIRST_DATE);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int startDateWeekDay=7-(calendar.get(Calendar.DAY_OF_WEEK)-2);
int endDateWeekDay=(365-startDateWeekDay)%7;
int totalWeek=(365-startDateWeekDay)/7+2;
int curWeek=today.get(Calendar.WEEK_OF_YEAR);
if(curWeek==1){
if((today.getTime().getMonth()+1)!=1){
curWeek=totalWeek;
}
}
sb.append("<table style='table-layout:fixed;' bgcolor='#C7D3E4' border='0' cellspacing='0' cellpadding='0' WIDTH='100%' align='left' >");
sb.append(" <tr style='background:url(../images/Common/tabletitle.gif) repeat-x;height:15px;color:#29384a;font-weight:bold;font-size:11px;'>");
int startWidthPixel=0;
int endWidthPixel=0;
int tempCount=0;
for(int i=0; i<totalWeek; i++){
int tempWidth=50;
if(i==0){
tempWidth=Float.valueOf((float)50/100*((float)100/7*startDateWeekDay)).intValue();
startWidthPixel=tempWidth;
}else if(i==totalWeek-1){
tempWidth=Float.valueOf((float)50/100*(100/7*endDateWeekDay)).intValue();
endWidthPixel=tempWidth;
}
tempCount++;
sb.append("<td style='border:1px solid #C7D3E4;' width='"+tempWidth+"px'>");
if(tempCount==curWeek) {
sb.append(" <div style='position:relative; width:100%'><div id='curBarDiv' style='position:absolute;width:"+tempWidth+"px;height:10;z-index:2;filter:alpha(opacity=50);background-color:#F2E3BD;opacity:0.5;'></div><div>");
}
sb.append(" <div style='position:relative; width:100%' align='center'><font size='-3' align='center'>"+(i+1)+"W</font><div>");
sb.append("</td>");
}
sb.append(" </tr>");
sb.append(" <tr style='height:15px;'>");
sb.append(" <td colspan='"+totalWeek+"'>");
sb.append(" <table border='0' cellspacing='0' cellpadding='0' WIDTH='100%'>");
sb.append(" <tr style='background:url(../images/Common/tabletitle.gif) repeat-x;color:#29384a;font-weight:bold;font-size:11px;'>");
int totalWidthPixel=startWidthPixel+endWidthPixel+(50*(totalWeek-2));
int oneDayWidthPixel=totalWidthPixel/365;
int nDaysList[] = {31 , 28 , 31 , 30 ,31 ,30, 31, 31 , 30 ,31 ,30 ,31};
for(int i=0; i<nDaysList.length; i++){
int tempWidth=oneDayWidthPixel*nDaysList[i];
String tempWidthStr=tempWidth+"px";
if(i==nDaysList.length-1)tempWidthStr="*";
sb.append(" <td align='center' style=' border:1px solid #C7D3E4; border-left-style:none; border-top-style:none; border-bottom-style:none' width='"+tempWidthStr+"'>");
sb.append(" <font size='-2'>");
sb.append(i+1+"M");
sb.append( "</font>");
sb.append(" </td>");
}
sb.append(" </tr>");
sb.append(" </table>");
sb.append(" </td>");
sb.append(" </tr>");
while(ganttDao.next()){
rowCount++;
if (rowCount >= firstRowCount && rowCount <= lastRowCount) {
String startdate=(ganttDao.getStartDate()).toString().substring(0,10);
String enddate=(ganttDao.getEndDate()).toString().substring(0,10);
String duedate=(ganttDao.getDueDate()).toString().substring(0,10);
Calendar startdateCal=Calendar.getInstance();
startdateCal.setTime(ganttDao.getStartDate());
Calendar enddateCal=Calendar.getInstance();
enddateCal.setTime(ganttDao.getEndDate());
Calendar duedateCal=Calendar.getInstance();
duedateCal.setTime(ganttDao.getDueDate());
int startWeek=1;
int startWeekDay=1;
int endWeek=1;
int endWeekDay=1;
int dueWeek=1;
int dueWeekday=1;
if(ganttDao.getStartDate()!=null){
if(startdateCal.before(firstDate)){
startWeek = 1;
startWeekDay=7*(100/7)/10;
}else{
startWeek=startdateCal.get(Calendar.WEEK_OF_YEAR);
startWeekDay=(7-(startdateCal.get(Calendar.DAY_OF_WEEK)-1))*(100/7)/10;
if(startWeek==1){
if(!startdate.substring(5,7).equals("01")){
startWeek=totalWeek;
}
}
}
}else{
startWeek=now.get(Calendar.WEEK_OF_YEAR);
startWeekDay =(7-(now.get(Calendar.DAY_OF_WEEK)-1))*(100/7)/10;
}
if(ganttDao.getEndDate()!=null){
if(enddateCal.before(firstDate)){
endWeek = 1;
endWeekDay = 7*(100/7)/10;
}else{
endWeek=enddateCal.get(Calendar.WEEK_OF_YEAR);
endWeekDay=(100-(7-(enddateCal.get(Calendar.DAY_OF_WEEK)-1))*(100/7))/10;
if(endWeek==1){
if(!enddate.substring(5,7).equals("01")){
endWeek=totalWeek;
}
}
}
}else{
endWeek=now.get(Calendar.WEEK_OF_YEAR);
endWeekDay =(7-(now.get(Calendar.DAY_OF_WEEK)-1))*(100/7)/10;
}
if(ganttDao.getDueDate()!=null){
if(duedateCal.before(firstDate)){
dueWeek = 0;
dueWeekday = 0;
}else if(duedateCal.after(lastDate)){
dueWeek = 12;//implicitly make it out of bound
dueWeekday = 7*(100/7)/10;
}else{
dueWeek=duedateCal.get(Calendar.WEEK_OF_YEAR);
dueWeekday=(100-(7-(duedateCal.get(Calendar.DAY_OF_WEEK)-1))*(100/7))/10;
if(dueWeek==1){
if(!duedate.substring(5,7).equals("01")){
dueWeek=totalWeek;
}
}
}
}else{
dueWeek=now.get(Calendar.WEEK_OF_YEAR);
dueWeekday =(7-(now.get(Calendar.DAY_OF_WEEK)-1))*(100/7)/10;
}
int drawEndWeek=dueWeek>endWeek?dueWeek:endWeek;
//System.out.println(startWeek+" "+startWeekDay+" "+endWeek+" "+endWeekDay);
float start=(float)(startWeek*10+startWeekDay)/10;
float end=(float)(endWeek*10+endWeekDay)/10;;
float dueDate=(float)(dueWeek*10+dueWeekday)/10;
float drawingEnd=(float)dueDate>end?dueDate:end;
//System.out.println(start+" "+end);
String status=ganttDao.getStatus();
if(!ganttDao.getStatus().equals("COMPLETED") && dueDate < end){
status="DELAY";
}
String processInstanceLabel;
if(orderby.equals("instance")){
if(oldProcessInstance.equals(""+ganttDao.getInstId())){
processInstanceLabel = "";
}else{
processInstanceLabel = ganttDao.get("name") + " ("+ganttDao.getInstId()+")";
oldProcessInstance = ""+ganttDao.getInstId();
if(rowCount>1){
sb.append("<tr><td height='15px' colspan='"+totalWeek+"' bgcolor='#FFFFFF' style='border:none;'></td></tr>");
}
sb.append("<tr class='gantable'>");
sb.append(" <td colspan='"+totalWeek+"' bgcolor='#FFFFFF' style='padding-left:5px; height:30px;'><span class='sectiontitle' >");
sb.append(" ");
sb.append(" </td>");
sb.append("</tr>");
}
String userName = ganttDao.getResName();
sb.append("<tr class='gantable'>");
for(int j=1; j<startWeek; j++){
sb.append("<td bgcolor=white></td>");
}
GanttChartUtil ganttChartUtil = new GanttChartUtil(now,"white","week");
String chartBar = ganttChartUtil.getGanttChartBarHtml(start,drawingEnd, end, dueDate, status);
sb.append(chartBar);
for(int j=drawEndWeek+1; j<=totalWeek; j++){
sb.append("<td bgcolor=white></td>");
}
sb.append("</tr>");
}else{
String userName = ganttDao.getResName();
if(oldResName.equals(""+userName)){
userName = "";
}else{
oldResName = ""+userName;
if(rowCount>1){
sb.append("<tr><td height='15px' colspan='"+totalWeek+"' bgcolor='#FFFFFF' style='border:none;'></td></tr>");
}
sb.append("<tr class='gantable'>");
sb.append(" <td colspan='"+totalWeek+"' bgcolor='#FFFFFF' style='padding-left:5px; height:30px;'><span class='sectiontitle' >");
sb.append(" ");
sb.append(" </td>");
sb.append("</tr>");
}
sb.append("<tr class='gantable'>");
for(int j=1; j<startWeek; j++){
sb.append("<td bgcolor=white></td>");
}
GanttChartUtil ganttChartUtil = new GanttChartUtil(now,"white","week");
String chartBar = ganttChartUtil.getGanttChartBarHtml(start,drawingEnd, end, dueDate, status);
sb.append(chartBar);
for(int j=drawEndWeek+1; j<=totalWeek; j++){
sb.append("<td bgcolor=white></td>");
}