<?php

namespace app\enterprise\controller;

use app\admin\model\Enterprise;
use app\enterprise\common\EnterpriseController;
use app\common\api\DictApi;

/**
 * Description of Index
 *
 * @author sgq
 */
class Index extends EnterpriseController {

    public function index() {
        $vars["user"] = [
            "name" => $this->user["name"],
            "rolename" => $this->user["rolename"],
            "avatar" => $this->user["avatar"]
        ];
        $menus = \app\common\api\MenuApi::getEnterpriseMenuByType($this->user["type"]);
        $vars["menus"] = $menus;
        return view("", $vars);
    }

    public function centerPage(){
        $ep = Enterprise::where('id',$this->user['uid'])->find();
        $ep['industryFieldNewName'] = DictApi::findDictByCode($ep['industryFieldNew'])->name ?? '';
        $ep['industryFieldOldName'] = DictApi::findDictByCode($ep['industryFieldOldName'])->name ?? '';
        $ep['talentTypeName'] = DictApi::findDictByCode($ep['talentType'])->name ?? '';
        $ep['streetName'] = DictApi::findDictByCode($ep['street'])->name ?? '';
        switch ($ep['type']){
            case 1:
                $ep['typeName'] = '晋江市优秀人才';
                break;
            case 2:
                $ep['typeName'] = '集成电路优秀人才';
                break;
            case 3:
                $ep['typeName'] = '海峡计划团队';
                break;
        }
        switch ($ep['checkState']){
            case 1:
                $ep['checkStateName'] = '待审核';
                break;
            case 2:
                $ep['checkStateName'] = '审核驳回';
                break;
            case 3:
                $ep['checkStateName'] = '审核通过';
                break;
            case 4:
                $ep['checkStateName'] = '重新提交';
                break;
        }
        switch ($ep['active']){
            case 1:
                $ep['activeName'] = '账号有效';
                break;
            case 2:
                $ep['activeName'] = '冻结/拉黑';
                break;
        }


        return view("", ['ep' => $ep]);
    }



}
