Changeset 1495


Ignore:
Timestamp:
Jan 9, 2012, 12:48:14 PM (10 years ago)
Author:
Martin Svensson
Message:

References #339 Removed debug-print and corrected a couple of miscalculations when generating estimating the number of columns.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/samplereportgenerator.jsp

    r1494 r1495  
    2727  <script language="JavaScript">
    2828  var currentStep = 1;
    29   var debug = true;
     29  var debug = false;
    3030  var sitesCombined;
    3131  var numCols;
     
    166166      reportTable = messageTable;     
    167167    }
    168     cellElement.appendChild(reportTable);   
     168    setInnerHTML('reportcell', '');
     169    cellElement.appendChild(reportTable);
    169170    Main.show('gorestart');   
    170171  }
     
    173174  {
    174175    var reportTable = getReportTable();
    175     var sdString = report.startDate;
    176     var edString = report.endDate;
    177     var ldString = report.latestDate;   
     176    var sdString = report.beginDate;
     177    var edString = report.endDate;   
    178178    var startDate = new Date();
    179179    startDate.setYear(sdString.substr(0,4));
     
    184184    endDate.setMonth(edString.substr(4,2)-1);
    185185    endDate.setDate(edString.substr(6));
    186     var latestDate = new Date();
    187     latestDate.setYear(ldString.substr(0,4));
    188     latestDate.setMonth(ldString.substr(4,2)-1);
    189     latestDate.setDate(ldString.substr(6));
    190186    var viewType = report.viewType;   
    191187 
     
    215211    else if (viewType == 'QUARTER')
    216212    {
    217       numCols = (endDate.getFullYear()-startDate.getFullYear())*4 + Math.ceil((endDate.getMonth()-startDate.getMonth())/3);
     213      numCols = (endDate.getFullYear()-startDate.getFullYear())*4 + Math.ceil((endDate.getMonth()-startDate.getMonth())/3)+1;
    218214      headerText += 'quarters';
    219215    }
     
    247243    {
    248244      subHeaderRowYear.appendChild(getTableCellElement('', 'reportsubheader', 2));
    249       addYearSubHeaders(startDate, endDate, latestDate, subHeaderRowYear, viewType);     
     245      addYearSubHeaders(startDate, endDate, subHeaderRowYear, viewType);     
    250246      subHeaderRowYear.appendChild(getTableCellElement('', 'reportsubheader'));
    251247    }   
     
    260256    else if (viewType == 'WEEK') addWeekColumnHeaders(columnHeaderRow, startDate);
    261257    else if (viewType == 'QUARTER') addQuarterColumnHeaders(columnHeaderRow, startDate);
    262     else if (viewType == 'YEAR') addYearSubHeaders(startDate, endDate, latestDate, columnHeaderRow, viewType);
     258    else if (viewType == 'YEAR') addYearSubHeaders(startDate, endDate, columnHeaderRow, viewType);
    263259   
    264260   
     
    281277    {
    282278      sitesCombinedRow.appendChild(getTableCellElement(sitesCombined[key],'colsummary'));
    283       gt += sitesCombined[key];
     279      if (sitesCombined[key] != '') gt += sitesCombined[key];
    284280    }
    285281    sitesCombinedRow.appendChild(getTableCellElement(gt, 'colsummary'));
     
    328324  }
    329325 
    330   function addYearSubHeaders(startDate, endDate, latestDate, subHeaderRowYear, vt)
     326  function addYearSubHeaders(startDate, endDate, subHeaderRowYear, vt)
    331327  {   
    332328    var currentYear = startDate.getFullYear(); 
     
    339335      if (vt == "MONTH")
    340336      {
    341         if (currentYear == startDate.getFullYear())
    342           colspan =  (12-parseInt(startDate.getMonth()+1)+1);
     337        if (currentYear == startDate.getFullYear())
     338        {
     339          colspan =  11-parseInt(startDate.getMonth())+1;
     340          if (endDate.getFullYear() == currentYear)
     341          {
     342            colspan = colspan - (11-parseInt(endDate.getMonth()));
     343          }
     344        }
    343345        else if (currentYear == endDate.getFullYear())
    344346          colspan = parseInt(endDate.getMonth()+1);
     
    406408  function addDataRowsToTable(report, reportTable)
    407409  {
    408     var fdString = report.startDate;
     410    var fdString = report.beginDate;
    409411    var ldString = report.endDate;
    410412    var startDate = new Date();
     
    469471          {
    470472            data = '';
    471             sitesCombined[keyIndex] = 0;
    472           }
    473           else if (sitesCombined[keyIndex] == null) sitesCombined[keyIndex] = data;
     473            if (sitesCombined[keyIndex] == null) sitesCombined[keyIndex] = data;
     474          }
     475          else if (sitesCombined[keyIndex] == null || sitesCombined[keyIndex] == '') sitesCombined[keyIndex] = data;
    474476          else sitesCombined[keyIndex] += data;
    475477          currentDate.setMonth(currentDate.getMonth()+3);         
     
    487489          if (currentDate.getFullYear() <= siteStartDate.getFullYear() && (monthIndex-1) < siteStartDate.getMonth())
    488490          {
    489             data = '';           
    490           }
    491           else if (sitesCombined[keyIndex] == null) sitesCombined[keyIndex] = data;
     491            data = '';
     492            if (sitesCombined[keyIndex] == null) sitesCombined[keyIndex] = data;
     493          }
     494          else if (sitesCombined[keyIndex] == null || sitesCombined[keyIndex] == '') sitesCombined[keyIndex] = data;
    492495          else sitesCombined[keyIndex] += data;
     496         
    493497         
    494498          currentDate.setMonth(currentDate.getMonth()+1);
     
    506510          {
    507511            data = '';
    508           }
    509           else if (sitesCombined[keyIndex] == null) sitesCombined[keyIndex] = data;
     512            if (sitesCombined[keyIndex] == null) sitesCombined[keyIndex] = data;
     513          }
     514          else if (sitesCombined[keyIndex] == null || sitesCombined[keyIndex] == '') sitesCombined[keyIndex] = data;
    510515          else sitesCombined[keyIndex] += data;
    511516          currentDate.setDate(currentDate.getDate()+7);
     
    515520        columnCounter++;       
    516521      }while (columnCounter< numCols)     
    517       tableRow.appendChild(getTableCellElement(grandTotal, 'rowsummary'));
     522      tableRow.appendChild(getTableCellElement(parseInt(grandTotal), 'rowsummary'));
    518523      reportTable.appendChild(tableRow);
    519524    }
     
    646651        <tr>
    647652          <td id="reportcell" class="stepfields">
     653            <i>Generating report...</i>
    648654          </td>
    649655        </tr>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SampleReportServlet.java

    r1494 r1495  
    178178        if (jsonReport.size() > 0)
    179179        {
     180          if (viewType == null) viewType = getViewType(startDate, endDate);
    180181          jsonReport.put("viewType", viewType);
    181           jsonReport.put("startDate", date2StringConverter.convert(startDate));
     182          jsonReport.put("beginDate", date2StringConverter.convert(startDate));
    182183          jsonReport.put("endDate", date2StringConverter.convert(endDate));
    183           jsonReport.put("latestDate", date2StringConverter.convert(latestDate));
    184184          json.put("report", jsonReport);
    185185        }
     
    251251    int currentQuarter = limitQuarterView.get(Calendar.MONTH)/3;
    252252    limitQuarterView.add(Calendar.MONTH, (3*currentQuarter)-limitQuarterView.get(Calendar.MONTH));
    253    
    254     System.out.println(limitWeekView.getTime());       
     253               
    255254    if (limitWeekView.after(endCal)) viewType = weekView;
    256255    else if (limitMonthView.after(endCal)) viewType = monthView;
Note: See TracChangeset for help on using the changeset viewer.