config = [ // "总后台首页", "财政局首页", "公司首页", "业主首页", "项目看板", // "用户管理", "项目管理", // 公司 "项目管理", // 财政局 "项目管理", // 业主 "合同管理", "请款详情", "数据统计", //财政局 "系统工具", // "系统管理", ]; } public function index() { $admin = get_login_admin(); if (get_cache('menu' . $admin['id'])) { $list = get_cache('menu' . $admin['id']); } else { $adminGroup = Db::name('AdminGroupAccess')->where(['uid' => get_login_admin('id')])->column('group_id'); $adminMenu = Db::name('AdminGroup')->where('id', 'in', $adminGroup)->column('rules'); $adminMenus = []; foreach ($adminMenu as $k => $v) { $v = explode(',', $v); $adminMenus = array_merge($adminMenus, $v); } $menu = Db::name('AdminRule')->where(['menu' => 1, 'status' => 1])->where('id', 'in', $adminMenus)->order('sort asc')->select()->toArray(); // halt($menu); $list = list_to_tree($menu); \think\facade\Cache::tag('adminMenu')->set('menu' . $admin['id'], $list); } $unit_name = Db::name("department")->where("id", get_login_admin("unit_name"))->value("title"); $theme = Db::name('Admin')->where('id', $admin['id'])->value('theme'); $type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type"); $red = Db::name("new_msg")->where("uid", "=", $admin['id'])->select(); // halt($red); $isreds = array(); if ($admin['user_type'] == 0) { if ($red) { foreach ($red as $key => $value) { if ($value['detail'] == 1 || $value['comment'] == 1 || $value['user'] == 1 || $value['contact'] == 1) { array_push($isreds, 1); } else { array_push($isreds, 0); } } } $daishen = Db::name("project_audit")->where(["audit_status" => 1, "approver" => $admin['id']])->count(); if ($daishen !== 0) { // $list['160']['isred'] = 1; // $list['160']['list']['195']['isred'] = 1; if(isset($list['192']['list']['194'])){ $list['192']['list']['194']['isred'] = 1; if(isset($list['192'])){ $list['192']['isred'] = 1; } } } $appropriation = Db::name("appropriation")->where(["status" => 1, "entrust_unit" => get_login_admin("unit_name")])->count(); if ($appropriation !== 0) { // $list['160']['isred'] = 1; // $list['160']['list']['195']['isred'] = 1; if(isset($list['378']['list']['379'])){ $list['378']['list']['379']['isred'] = 1; if(isset($list['378'])){ $list['378']['isred'] = 1; } } } } else if ($admin['user_type'] == 2) { if ($red) { foreach ($red as $key => $value) { if ($value['detail'] == 1 || $value['comment'] == 1 || $value['record'] == 1 || $value['user'] == 1 || $value['contact'] == 1) { array_push($isreds, 1); } else { array_push($isreds, 0); } } } $daijie = Db::name("cost_project")->where(["project_status" => 3,"review_unit"=>get_login_admin("unit_name")])->count(); if ($daijie !== 0) { if(isset($list['160']['list']['195'])){ $list['160']['list']['195']['isred'] = 1; if(isset($list['160'])){ $list['160']['isred'] = 1; } } } $daishen = Db::name("project_audit")->where(["audit_status" => 1, "approver" => $admin['id']])->count(); if ($daishen !== 0) { // $list['160']['isred'] = 1; // $list['160']['list']['195']['isred'] = 1; if(isset($list['160']['list']['401'])){ $list['160']['list']['401']['isred'] = 1; if(isset($list['160'])){ $list['160']['isred'] = 1; } } } } if (in_array(1, $isreds)) { $isred = 1; if (array_key_exists(160, $list)) { if(isset($list['160']['list']['161'])){ $list['160']['list']['161']['isred'] = 1; if(isset($list['160'])){ $list['160']['isred'] = 1; } } } else if (array_key_exists(192, $list)) { if(isset($list['192']['list']['234'])){ $list['192']['list']['234']['isred'] = 1; if(isset($list['192'])){ $list['192']['isred'] = 1; } } } } else { $isred = 0; } if (get_login_admin('user_type') == -1) { foreach ($list as $key => $value) { if (in_array($value['title'], $this->config)) { unset($list[$key]); } } } View::assign('unit_name', $unit_name); View::assign('theme', $theme); View::assign('menu', $list); View::assign("type",$type); View::assign('red',$red); $count = 0; $unread_ids = Db::name("admin")->where("id",get_login_admin("id"))->value('unread'); if($unread_ids){ $unread_ids = explode(',',$unread_ids); $unread = Db::name('project_msg')->whereIn("id",$unread_ids)->select(); $count = count($unread); View::assign("unread",$unread); } View::assign('count',$count); return View(); } public function main() { $sent_review_amount = Db::name("cost_project")->where([ ["entrust_unit", "=", get_login_admin("unit_name")], ['delete_time', '=', 0], ["project_status", ">", 2], ["project_status", "<>", 9], ])->field("sent_review_amount,sent_review_cost,review_add_reduce_rate,authorize_amount,engineering_type1")->select(); //engineering_type1=1是预算,2是结算 $amount = [ //送审总额 'sent_review_amount' => 0, //评审服务费 'sent_review_cost' => 0, //审定总额 'authorize_amount' => 0, //总审减率 'review_add_reduce_rate' => 0 ]; $sent_review_amount_tol = [ "sent_review_amount_type1" => 0, "sent_review_amount_type2" => 0, "authorize_amount_type1" => 0, "authorize_amount_type2" => 0, "review_add_reduce_rate_type1" => 0, "review_add_reduce_rate_type2" => 0 ]; for ($i = 0; $i < count($sent_review_amount); $i++) { $a = $sent_review_amount[$i]; if ($a['engineering_type1'] == 1) { if ((int)$a["sent_review_amount"]) { //预算总额 $sent_review_amount_tol["sent_review_amount_type1"] += $a["sent_review_amount"]; } if ((int)$a["authorize_amount"]) { //审定 $sent_review_amount_tol["authorize_amount_type1"] += $a["authorize_amount"]; } } elseif ($a['engineering_type1'] == 2) { if ((int)$a["sent_review_amount"]) { //结算总额 $sent_review_amount_tol["sent_review_amount_type2"] += $a["sent_review_amount"]; } if ((int)$a["authorize_amount"]) { //审定 $sent_review_amount_tol["authorize_amount_type2"] += $a["authorize_amount"]; } } } //什么率的 $sentReviewAmount = 0; $authorizeAmount = 0; $sent_review_amount_type1 = 0; $authorize_amount_type1 = 0; $sent_review_amount_type2 = 0; $authorize_amount_type2 = 0; for ($i = 0; $i < count($sent_review_amount); $i++) { $a = $sent_review_amount[$i]; if ($a['engineering_type1'] == 1 && (int)$a["authorize_amount"]) { if ((int)$a["sent_review_amount"]) { //预算总额 $sent_review_amount_type1 += $a["sent_review_amount"]; //审定 $authorize_amount_type1 += $a["authorize_amount"]; } } elseif ($a['engineering_type1'] == 2) { if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) { //结算总额 $sent_review_amount_type2 += $a["sent_review_amount"]; //审定 $authorize_amount_type2 += $a["authorize_amount"]; } } if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) { //结算总额 $sentReviewAmount += $a["sent_review_amount"]; //审定 $authorizeAmount += $a["authorize_amount"]; } } if ((int)$sent_review_amount_type1 && (int)$authorize_amount_type1) { //预算核增减率 $sent_review_amount_tol["review_add_reduce_rate_type1"] = sprintf("%.4f", ($authorize_amount_type1 - $sent_review_amount_type1) / $sent_review_amount_type1) * 100; } if ($sent_review_amount_type2 && $authorize_amount_type2) { //结算核增减率 $sent_review_amount_tol["review_add_reduce_rate_type2"] = sprintf("%.4f", ($authorize_amount_type2 - $sent_review_amount_type2) / $sent_review_amount_type2) * 100; } if ((int)$sentReviewAmount && (int)$authorizeAmount) { $amount['review_add_reduce_rate'] = (sprintf("%.4f", ($authorizeAmount - $sentReviewAmount) / $sentReviewAmount)) * 100; } for ($i = 0; $i < count($sent_review_amount); $i++) { $a = $sent_review_amount[$i]; if ((int)$a['sent_review_amount']) { $amount["sent_review_amount"] += $a['sent_review_amount']; } if ((int)$a['sent_review_cost']) { $amount["sent_review_cost"] += $a['sent_review_cost']; } if ((int)$a['authorize_amount']) { $amount["authorize_amount"] += $a['authorize_amount']; } } //评审服务费,上半年服务费用,下半年服务费用 start $currentTime = time(); $year = date('Y', $currentTime); // 计算上半年时间范围 $firstHalfStart = strtotime($year . '-01-01'); $firstHalfEnd = strtotime($year . '-06-30 23:59:59'); // 计算下半年时间范围 $secondHalfStart = strtotime($year . '-07-01'); $secondHalfEnd = strtotime($year . '-12-31 23:59:59'); $first_sent_review_cost = Db::name("cost_project")->where([ ['delete_time', '=', 0], ["project_status", ">", 2], ["project_status", "<>", 9], ["entrust_unit", "=", get_login_admin("unit_name")] ])-> whereBetween('create_time', [$firstHalfStart, $firstHalfEnd])->field("sent_review_cost")->select()->toArray(); $second_sent_review_cost = Db::name("cost_project")->where([ ['delete_time', '=', 0], ["project_status", ">", 2], ["project_status", "<>", 9], ["entrust_unit", "=", get_login_admin("unit_name")] ])->whereBetween('create_time', [$secondHalfStart, $secondHalfEnd])->field("sent_review_cost")->select()->toArray(); $sent_review_cost = [ 'first_sent_review_cost' => 0, 'second_sent_review_cost' => 0 ]; for ($i = 0; $i < count($first_sent_review_cost); $i++) { $a = $first_sent_review_cost[$i]; $sent_review_cost["first_sent_review_cost"] += $a['sent_review_cost']; } for ($i = 0; $i < count($second_sent_review_cost); $i++) { $a = $second_sent_review_cost[$i]; $sent_review_cost["second_sent_review_cost"] += $a['sent_review_cost']; } //评审服务费,上半年服务费用,下半年服务费用 end //项目数量,正在作业,已归档 $num = Db::name("cost_project")->where([ ["entrust_unit", "=", get_login_admin("unit_name")], ['delete_time', '=', 0], ["project_status", '>', 0], ])->count(); $where = [ ["entrust_unit", "=", get_login_admin("unit_name")], ['delete_time', '=', 0], ["project_status", '>', 0], ]; $data = Db::name("cost_project")->where($where)->select(); $num_project = [ 'num' => 0, "yu" => 0, "jie" => 0, "zuo" => 0, "gui" => 0, "tui" => 0, ]; foreach ($data as $key => $value) { $num_project["num"] += 1; if ($value["project_status"] < 6 && $value["project_status"] > 3) { $num_project["zuo"] += 1; } if ($value["project_status"] < 8 && $value["project_status"] > 3) { if ($value["engineering_type1"] == 1) { $num_project["yu"] += 1; } if ($value["engineering_type1"] == 2) { $num_project["jie"] += 1; } } if ($value["project_status"] == 8) { $num_project["gui"] += 1; } if ($value["project_status"] == 9) { $num_project["tui"] += 1; } } //项目数量,正在作业,已归档 $sent_review_cost_real = []; foreach ($sent_review_cost as $item=>$value){ $sent_review_cost_real[$item] = number_format($value/10000,2,".",""); } $sent_review_amount_tol_real = []; foreach ($sent_review_amount_tol as $item=>$value){ if(!($item == "review_add_reduce_rate_type1" || $item == "review_add_reduce_rate_type2")){ $sent_review_amount_tol_real[$item] = number_format($value/10000,2,".",""); }else{ $sent_review_amount_tol_real[$item] = number_format($value,2,".",""); } } $amount_real = []; foreach ($amount as $item=>$value){ if($item=="review_add_reduce_rate"){ $amount_real[$item] = number_format($value,2,".",""); }else{ $amount_real[$item] = number_format($value/10000,2,".",""); } } View::assign("sent_review_cost", $sent_review_cost_real); View::assign("amount", $amount_real); View::assign("num", $num); View::assign("num_project", $num_project); View::assign("sent_review_amount_tol", $sent_review_amount_tol_real); // dump(self::getHomeFive()); View::assign("home_five", self::getHomeFive()); return View(); } public function main_company() { $sent_review_amount = Db::name("cost_project")->where([ ["review_unit", "=", get_login_admin("unit_name")], ['delete_time', '=', 0], ['project_status', '>', 3], ["project_status", "<>", 7], ["project_status", "<>", 9], ])->field("sent_review_amount,sent_review_cost,review_add_reduce_rate,authorize_amount,engineering_type1")->select(); //engineering_type1=1是预算,2是结算 $amount = [ //送审总额 'sent_review_amount' => 0, //评审服务费 'sent_review_cost' => 0, //审定总额 'authorize_amount' => 0, //总审减率 'review_add_reduce_rate' => 0 ]; $sent_review_amount_tol = [ "sent_review_amount_type1" => 0, "sent_review_amount_type2" => 0, "authorize_amount_type1" => 0, "authorize_amount_type2" => 0, "review_add_reduce_rate_type1" => 0, "review_add_reduce_rate_type2" => 0 ]; for ($i = 0; $i < count($sent_review_amount); $i++) { $a = $sent_review_amount[$i]; if ($a['engineering_type1'] == 1) { if ((int)$a["sent_review_amount"]) { //预算总额 $sent_review_amount_tol["sent_review_amount_type1"] += $a["sent_review_amount"]; } if ((int)$a["authorize_amount"]) { //审定 $sent_review_amount_tol["authorize_amount_type1"] += $a["authorize_amount"]; } } elseif ($a['engineering_type1'] == 2) { if ((int)$a["sent_review_amount"]) { //结算总额 $sent_review_amount_tol["sent_review_amount_type2"] += $a["sent_review_amount"]; } if ((int)$a["authorize_amount"]) { //审定 $sent_review_amount_tol["authorize_amount_type2"] += $a["authorize_amount"]; } } } //什么率的 $sentReviewAmount = 0; $authorizeAmount = 0; $sent_review_amount_type1 = 0; $authorize_amount_type1 = 0; $sent_review_amount_type2 = 0; $authorize_amount_type2 = 0; for ($i = 0; $i < count($sent_review_amount); $i++) { $a = $sent_review_amount[$i]; if ($a['engineering_type1'] == 1 && (int)$a["authorize_amount"]) { if ((int)$a["sent_review_amount"]) { //预算总额 $sent_review_amount_type1 += $a["sent_review_amount"]; //审定 $authorize_amount_type1 += $a["authorize_amount"]; } } elseif ($a['engineering_type1'] == 2) { if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) { //结算总额 $sent_review_amount_type2 += $a["sent_review_amount"]; //审定 $authorize_amount_type2 += $a["authorize_amount"]; } } if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) { //结算总额 $sentReviewAmount += $a["sent_review_amount"]; //审定 $authorizeAmount += $a["authorize_amount"]; } } if ((int)$sent_review_amount_type1 && (int)$authorize_amount_type1) { //预算核增减率 $sent_review_amount_tol["review_add_reduce_rate_type1"] = sprintf("%.4f", ($authorize_amount_type1 - $sent_review_amount_type1) / $sent_review_amount_type1) * 100; } if ($sent_review_amount_type2 && $authorize_amount_type2) { //结算核增减率 $sent_review_amount_tol["review_add_reduce_rate_type2"] = sprintf("%.4f", ($authorize_amount_type2 - $sent_review_amount_type2) / $sent_review_amount_type2) * 100; } if ((int)$sentReviewAmount && (int)$authorizeAmount) { $amount['review_add_reduce_rate'] = (sprintf("%.4f", ($authorizeAmount - $sentReviewAmount) / $sentReviewAmount)) * 100; } for ($i = 0; $i < count($sent_review_amount); $i++) { $a = $sent_review_amount[$i]; if ((int)$a['sent_review_amount']) { $amount["sent_review_amount"] += $a['sent_review_amount']; } if ((int)$a['sent_review_cost']) { $amount["sent_review_cost"] += $a['sent_review_cost']; } if ((int)$a['authorize_amount']) { $amount["authorize_amount"] += $a['authorize_amount']; } } //评审服务费,上半年服务费用,下半年服务费用 start $currentTime = time(); $year = date('Y', $currentTime); // 计算上半年时间范围 $firstHalfStart = strtotime($year . '-01-01'); $firstHalfEnd = strtotime($year . '-06-30 23:59:59'); // 计算下半年时间范围 $secondHalfStart = strtotime($year . '-07-01'); $secondHalfEnd = strtotime($year . '-12-31 23:59:59'); $first_sent_review_cost = Db::name("cost_project")->where([ ['project_status', '>', 3], ["review_unit", "=", get_login_admin("unit_name")], ["project_status", "<>", 7], ["project_status", "<>", 9] ])->whereBetween('create_time', [$firstHalfStart, $firstHalfEnd])->field("sent_review_cost")->select()->toArray(); $second_sent_review_cost = Db::name("cost_project")->where([ ['project_status', '>', 3], ["review_unit", "=", get_login_admin("unit_name")], ["project_status", "<>", 7], ["project_status", "<>", 9] ])->whereBetween('create_time', [$secondHalfStart, $secondHalfEnd])->field("sent_review_cost")->select()->toArray(); $sent_review_cost = [ 'first_sent_review_cost' => 0, 'second_sent_review_cost' => 0 ]; for ($i = 0; $i < count($first_sent_review_cost); $i++) { $a = $first_sent_review_cost[$i]; $sent_review_cost["first_sent_review_cost"] += $a['sent_review_cost']; } for ($i = 0; $i < count($second_sent_review_cost); $i++) { $a = $second_sent_review_cost[$i]; $sent_review_cost["second_sent_review_cost"] += $a['sent_review_cost']; } //评审服务费,上半年服务费用,下半年服务费用 end //项目数量,正在作业,已归档 $num = Db::name("cost_project")->where([ ["review_unit", "=", get_login_admin("unit_name")], ['delete_time', '=', 0], ["project_status", '>', 3], ])->count(); $where = [ ["review_unit", "=", get_login_admin("unit_name")], ['delete_time', '=', 0], ["project_status", '>', 2], ]; $data = Db::name("cost_project")->where($where)->select(); $num_project = [ 'num' => 0, "yu" => 0, "jie" => 0, "zuo" => 0, "gui" => 0, "tui" => 0, ]; foreach ($data as $key => $value) { $num_project["num"] += 1; if ($value["project_status"] < 6 && $value["project_status"] > 3) { $num_project["zuo"] += 1; } if ($value["project_status"] < 8 && $value["project_status"] > 3) { if ($value["engineering_type1"] == 1) { $num_project["yu"] += 1; } if ($value["engineering_type1"] == 2) { $num_project["jie"] += 1; } } if ($value["project_status"] == 8) { $num_project["gui"] += 1; } if ($value["project_status"] == 9) { $num_project["tui"] += 1; } } //项目数量,正在作业,已归档 $sent_review_cost_real = []; foreach ($sent_review_cost as $item=>$value){ $sent_review_cost_real[$item] = number_format($value/10000,2,".",""); } $sent_review_amount_tol_real = []; foreach ($sent_review_amount_tol as $item=>$value){ if(!($item == "review_add_reduce_rate_type1" || $item == "review_add_reduce_rate_type2")){ $sent_review_amount_tol_real[$item] = number_format($value/10000,2,".",""); }else{ $sent_review_amount_tol_real[$item] = number_format($value,2,".",""); } } $amount_real = []; foreach ($amount as $item=>$value){ if($item=="review_add_reduce_rate"){ $amount_real[$item] = number_format($value,2,".",""); }else{ $amount_real[$item] = number_format($value/10000,2,".",""); } } View::assign("sent_review_cost", $sent_review_cost_real); View::assign("amount", $amount_real); View::assign("num", $num); View::assign("num_project", $num_project); View::assign("sent_review_amount_tol", $sent_review_amount_tol_real); View::assign("home_five", self::getHomeFive_company()); return View(); } public function main_admin() { return View(); } //设置theme public function set_theme() { if (request()->isAjax()) { $param = get_params(); $admin = get_login_admin(); Db::name('Admin')->where('id', $admin['id'])->update(['theme' => $param['theme']]); return to_assign(); } else { return to_assign(1, '操作错误'); } } public function head() { $param = get_params(); // halt($param); $where = []; if(!empty($param["nickname"])){ $where = [["a.nickname","like","%".$param["nickname"]."%"]]; } $list = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id") ->where([["d.type", "=", 2], ["pid", "=", 0], ["d.status", "=", 1]])->where($where)->field("d.id,d.title,a.nickname,a.mobile,a.email")->select(); $datalist = [ "code" => 0, "count" => count($list), "data" => $list ]; return json($datalist); } public function cp_head(){ $param = get_params(); $where = []; if (!empty($param["nickname"])) { $where = [["a.nickname|d.title", "like", "%" . $param["nickname"] . "%"]]; } $list_entrust = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id") ->where([["d.type", "=", 0], ["pid", "=", 0], ["d.status", "=", 1]]) ->where($where) ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email") ->select()->toArray(); $list_proprietor = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id") ->where([["d.type", "=", 1], ["pid", "=", 0], ["d.status", "=", 1]]) ->where($where) ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email") ->select()->toArray(); $list_exterior = array_merge($list_proprietor,$list_entrust); $datalist = [ "code" => 0, "count" => count($list_exterior), "data" => $list_exterior ]; return json($datalist); } public function cp_people(){ $list = Db::name("admin")->alias("a")->where("a.unit_name",get_login_admin("unit_name")) ->join("department d","a.did=d.id","left") ->field("a.id,d.title,a.nickname,a.mobile,a.email")->select(); $datalist = [ "code" => 0, "count" => count($list), "data" => $list ]; return json($datalist); } /** * 公司通讯录 */ public function people(){ $p = get_params(); $where = array(); if (!empty($p['nickname'])) { $where[] = ['a.nickname', 'like', "%".$p['nickname']."%"]; } $list = Db::name('admin')->where("a.unit_name",get_login_admin("unit_name"))->alias('a') ->join("department d","a.unit_name=d.id","left") ->field("a.*,d.title")->where("a.status",1) ->where($where) ->select(); $datalist = [ "code" => 0, "count" => count($list), "data" => $list ]; return json($datalist); } public function getHomeFive() { $where = [ ['name', '=', '待审核任务'], ['name', '=', '临期项目-财政局'], ['name', '=', '逾期项目-财政局'], ['name', '=', '项目列表-财政局'], ['name', '=', '通讯录-财政局'], ]; $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray(); $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id'); $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules'); $login_rules = explode(',', $login_rules); $rules_id = array(); foreach ($list as $key => $value) { if ($value['name'] == "待审核任务") { if (in_array($value['id'], $login_rules)) { $rules_id['audit_project'] = 1; } else { $rules_id['audit_project'] = 0; } } else if ($value['name'] == "临期项目-财政局") { if (in_array($value['id'], $login_rules)) { $rules_id['imminent_project'] = 1; } else { $rules_id['imminent_project'] = 0; } } else if ($value['name'] == "逾期项目-财政局") { if (in_array($value['id'], $login_rules)) { $rules_id['overdue_item'] = 1; } else { $rules_id['overdue_item'] = 0; } } else if ($value['name'] == "项目列表-财政局") { if (in_array($value['id'], $login_rules)) { $rules_id['list_project'] = 1; } else { $rules_id['list_project'] = 0; } } else if ($value['name'] == "通讯录-财政局") { if (in_array($value['id'], $login_rules)) { $rules_id['address_book'] = 1; } else { $rules_id['address_book'] = 0; } } } return $rules_id; } public function getHomeFive_company() { $where = [ ['name', '=', '待接收项目_公司首页'], ['name', '=', '临期项目-公司'], ['name', '=', '逾期项目-公司'], ['name', '=', '项目列表-公司'], ['name', '=', '通讯录-公司'], ]; $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray(); // halt($list); $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id'); $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules'); $login_rules = explode(',', $login_rules); // halt($login_rules); $rules_id = array(); foreach ($list as $key => $value) { if ($value['name'] == "待接收项目_公司首页") { if (in_array($value['id'], $login_rules)) { $rules_id['audit_project'] = 1; } else { $rules_id['audit_project'] = 0; } } else if ($value['name'] == "临期项目-公司") { if (in_array($value['id'], $login_rules)) { $rules_id['imminent_project'] = 1; } else { $rules_id['imminent_project'] = 0; } } else if ($value['name'] == "逾期项目-公司") { if (in_array($value['id'], $login_rules)) { $rules_id['overdue_item'] = 1; } else { $rules_id['overdue_item'] = 0; } } else if ($value['name'] == "项目列表-公司") { if (in_array($value['id'], $login_rules)) { $rules_id['list_project'] = 1; } else { $rules_id['list_project'] = 0; } } else if ($value['name'] == "通讯录-公司") { if (in_array($value['id'], $login_rules)) { $rules_id['address_book'] = 1; } else { $rules_id['address_book'] = 0; } } } // halt($rules_id); return $rules_id; } }