123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913 |
- <?php
- /**
- * @copyright Copyright (c) 2021 勾股工作室
- * @license https://opensource.org/licenses/Apache-2.0
- * @link https://www.gougucms.com
- */
- declare (strict_types=1);
- namespace app\admin\controller;
- use app\admin\BaseController;
- use think\facade\Db;
- use think\facade\View;
- class Index extends BaseController
- {
- public $config;
- public function __construct()
- {
- // 总后台不要的页面
- $this->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;
- }
- }
|