package cn.net.caoyao.cpzshandset.service.presenter.impl.upload.liqueurSFY;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.Intent;

import cn.net.caoyao.cpzshandset.common.config.HandsetOperation;
import cn.net.caoyao.cpzshandset.service.bll.UploadStatusBll;
import cn.net.caoyao.cpzshandset.service.presenter.UploadStatusConstact;
import cn.net.caoyao.cpzshandset.service.presenter.base.impl.UploadStatusConstactImpl;
import cn.net.caoyao.cpzshandset.ui.adapter.UploadStatusAdapter;
import cn.net.cpzslibs.prot.handset.bean.res.ResponsibleUserInfoBean;

public class LiqueurSFYUploadStatusPresenter extends UploadStatusConstactImpl{

	private final UploadStatusConstact.View uView;
	private Context context;
	private List<String> dates = new ArrayList<>();
//	private List<HomeBean> homeBeans = new ArrayList<>();
	private List<HandsetOperation> options = new ArrayList<>();
	private UploadStatusBll uploadStatusBll;
	private ResponsibleUserInfoBean uBean;
	public LiqueurSFYUploadStatusPresenter(UploadStatusConstact.View uView,Context context,Intent intent) {
		this.uView = uView;
		this.context = context;
		uBean = (ResponsibleUserInfoBean) intent.getSerializableExtra("userInfo");
		start();
	}
	
	@Override
	public void start() {
		if (!checkViewAvailable()) return;
		init();
		uView.setPageTitle("提交状态");
		uView.setAdapter(new UploadStatusAdapter(dates, options, uploadStatusBll));
	}

	private void init() {
		uploadStatusBll = new UploadStatusBll(context);
		if (uBean.getUserType() == 1) {
			//仓库
			options.add(HandsetOperation.OPERATION_ACTIVATE_WITH_RELATION_CONSTANT);
			options.add(HandsetOperation.OPERATION_OUT_WAREHOUSE_CONSTANT);
		}
		options.add(HandsetOperation.OPERATION_SALE_CONSTANT);
		options.add(HandsetOperation.OPERATION_RETURNED_GOODS_CONSTANT);
		
		dates = uploadStatusBll.queryUploadDateFor7Days();
//		LogUtil.d(TConfig.Echo, "提交状态：" + dates.toString());
	}

	@Override
	public boolean checkViewAvailable() {
		boolean b = false;
        if (uView != null && context != null) {
            b = true;
        }
        return b;
	}

	


}
