package com.wd.workoffice.ui.activity.bat.work;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;

import com.wd.workoffice.R;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.workEnum.PagePermissionType;
import com.wd.workoffice.util.WorkUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 工作台 - 财务
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class WorkFinancialActivity extends WorkToolBarActivity {

    @BindView(R.id.ll_back)
    LinearLayout llBack;
    @BindView(R.id.ll_pay)
    LinearLayout llPay;
    @BindView(R.id.ll_open_ticket)
    LinearLayout llOpenTicket;
    @BindView(R.id.ll_receive_ticket)
    LinearLayout llReceiveTicket;
    @BindView(R.id.ll_account)
    LinearLayout llAccount;
    @BindView(R.id.ll_logistics)
    LinearLayout llLogistics;

    @Override
    protected void initView() {
        ButterKnife.bind(this);
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void initEvent() {
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_work_financial;
    }


    @OnClick({R.id.ll_profit, R.id.ll_back, R.id.ll_pay, R.id.ll_open_ticket, R.id.ll_receive_ticket, R.id.ll_account, R.id.ll_logistics})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_profit:
                if (!WorkUtils.hasPermission(PagePermissionType.SALE_ORDER_AUDIT.getPermission()) &&
                        !WorkUtils.hasPermission(PagePermissionType.PO_PURCHASE_AUDIT.getPermission())) {
                    toast(R.string.permission);
                    return;
                }
                startActivity(WorkFinancialProfitActivity.class);
                break;
            case R.id.ll_back:
                if (!WorkUtils.hasPermission(PagePermissionType.MONEY_BACK_LIST.getPermission())) {
                    toast(R.string.permission);
                    return;
                }
                startActivity(WorkFinancialOutActivity.class);
                break;
            case R.id.ll_pay:
                if (!WorkUtils.hasPermission(PagePermissionType.MONEY_PAY_LIST.getPermission())) {
                    toast(R.string.permission);
                    return;
                }
                startActivity(WorkFinancialPayActivity.class);
                break;
            case R.id.ll_open_ticket:
                if (!WorkUtils.hasPermission(PagePermissionType.SO_INVOICE_LIST.getPermission()) &&
                        !WorkUtils.hasPermission(PagePermissionType.PO_INVOICE_LIST.getPermission()) && !WorkUtils.hasPermission(PagePermissionType.CO_INVOICE_LIST.getPermission())) {
                    toast(R.string.permission);
                    return;
                }
                startActivity(WorkFinancialTicketActivity.class);
                break;
            case R.id.ll_receive_ticket:
                if (!WorkUtils.hasPermission(PagePermissionType.FO_RECEIPT_LIST.getPermission()) &&
                        !WorkUtils.hasPermission(PagePermissionType.PO_RECEIPT_LIST.getPermission())) {
                    toast(R.string.permission);
                    return;
                }
                startActivity(WorkFinancialReceiveTicketActivity.class);
                break;
            case R.id.ll_account:
                if (!WorkUtils.hasPermission(PagePermissionType.FINANCE_DEPT_LIST.getPermission())) {
                    toast(R.string.permission);
                    return;
                }
                startActivity(WorkFinancialAccountActivity.class);
                break;
            case R.id.ll_logistics:
                if (!WorkUtils.hasPermission(PagePermissionType.LOGISTICS_APPLY_PAGE.getPermission())){
                    toast(R.string.permission);
                    return;
                }
                startActivity(WorkLogisticActivity.class);
                break;
        }
    }
}
