var estatementDownload = new Component("estatementDownload");

app.registerComponent(estatementDownload);

estatementDownload.on("load", function (){
    var self = this;
    return this.render("template/estatement_download.html",
            "estatement", null).done(function(){
                self.trigger("reloadDownloadList");
            });
    }
);

estatementDownload.on("reloadDownloadList", function(){
    var requestData = app.selectBpKey == "" ? {data: {result:[]}} : "eStatement/list/" + app.selectBpKey;   
    return this.render("template/estatement_download_file_list.html",
        "estatementDownloadFileList", requestData).done(function(){
            $("#estatementDownloadFileList").css({"min-height":"20px"});
       }                    
    );    
});

estatementDownload.download = function(id){
    trackAction("EStatement - Download");
	var cnumber = getCookie("cnumber");
    var downloadUrl = app.EPRESTAPI_CONTEXT_ROOT + "eStatement/" + id+"?cnumber="+cnumber;
    window.open(downloadUrl);
};
