package com.aimluck.eip.book;

import jp.co.imtt.businesssystem.common.IMXlsWriter;
import org.apache.turbine.util.RunData;
import org.apache.velocity.context.Context;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class BookWorkXlsWriter extends IMXlsWriter {
  
  public static final String FILE_NAME = "作業集計";
  private static final String SHEET_NAME = "";
  private static final String TEMPLATE_NAME  = "template_work";
  
  public BookWorkXlsWriter(){
    // テンプレートファイル名をセット
    setTemplateName(TEMPLATE_NAME);
    // シート名をセット
    setSheetName(SHEET_NAME);
    // 出力ファイル名をセット
    setFileName(FILE_NAME);
  }
  
  @Override
  public boolean write(RunData rundata, Context context, HSSFWorkbook wb){

    if (wb == null) return true;
    
    // 受注+担当者別集計
    IMXlsWriter writer1 = new BookWork1XlsWriter();
    // 担当者＋受注＋作業区分別集計
    IMXlsWriter writer2 = new BookWork2XlsWriter();
    // 受注＋作業区分＋担当者別集計
    IMXlsWriter writer3 = new BookWork3XlsWriter();
    // 受注別集計
    IMXlsWriter writer4 = new BookWork4XlsWriter();
    // 担当者日付別集計
    IMXlsWriter writer5 = new BookWork5XlsWriter();
    // 担当者別集計
    IMXlsWriter writer6 = new BookWork6XlsWriter();
    
    // 帳票データ書き込み
    boolean res =
      writer1.write(rundata, context, wb) &&
      writer2.write(rundata, context, wb) &&
      writer3.write(rundata, context, wb) &&
      writer4.write(rundata, context, wb) &&
      writer5.write(rundata, context, wb) &&
      writer6.write(rundata, context, wb);
    
    return res;
  }
  
}
