Index.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2021 勾股工作室
  4. * @license https://opensource.org/licenses/Apache-2.0
  5. * @link https://www.gougucms.com
  6. */
  7. declare (strict_types=1);
  8. namespace app\admin\controller;
  9. use app\admin\BaseController;
  10. use think\facade\Db;
  11. use think\facade\View;
  12. class Index extends BaseController
  13. {
  14. public $config;
  15. public function __construct()
  16. {
  17. // 总后台不要的页面
  18. $this->config = [
  19. // "总后台首页",
  20. "财政局首页",
  21. "公司首页",
  22. "业主首页",
  23. "项目看板",
  24. // "用户管理",
  25. "项目管理", // 公司
  26. "项目管理", // 财政局
  27. "项目管理", // 业主
  28. "合同管理",
  29. "请款详情",
  30. "数据统计", //财政局
  31. "系统工具",
  32. // "系统管理",
  33. ];
  34. }
  35. public function index()
  36. {
  37. $admin = get_login_admin();
  38. if (get_cache('menu' . $admin['id'])) {
  39. $list = get_cache('menu' . $admin['id']);
  40. } else {
  41. $adminGroup = Db::name('AdminGroupAccess')->where(['uid' => get_login_admin('id')])->column('group_id');
  42. $adminMenu = Db::name('AdminGroup')->where('id', 'in', $adminGroup)->column('rules');
  43. $adminMenus = [];
  44. foreach ($adminMenu as $k => $v) {
  45. $v = explode(',', $v);
  46. $adminMenus = array_merge($adminMenus, $v);
  47. }
  48. $menu = Db::name('AdminRule')->where(['menu' => 1, 'status' => 1])->where('id', 'in', $adminMenus)->order('sort asc')->select()->toArray();
  49. // halt($menu);
  50. $list = list_to_tree($menu);
  51. \think\facade\Cache::tag('adminMenu')->set('menu' . $admin['id'], $list);
  52. }
  53. $unit_name = Db::name("department")->where("id", get_login_admin("unit_name"))->value("title");
  54. $theme = Db::name('Admin')->where('id', $admin['id'])->value('theme');
  55. $type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
  56. $red = Db::name("new_msg")->where("uid", "=", $admin['id'])->select();
  57. // halt($red);
  58. $isreds = array();
  59. if ($admin['user_type'] == 0) {
  60. if ($red) {
  61. foreach ($red as $key => $value) {
  62. if ($value['detail'] == 1 || $value['comment'] == 1 || $value['user'] == 1 || $value['contact'] == 1) {
  63. array_push($isreds, 1);
  64. } else {
  65. array_push($isreds, 0);
  66. }
  67. }
  68. }
  69. $daishen = Db::name("project_audit")->where(["audit_status" => 1, "approver" => $admin['id']])->count();
  70. if ($daishen !== 0) {
  71. // $list['160']['isred'] = 1;
  72. // $list['160']['list']['195']['isred'] = 1;
  73. if(isset($list['192']['list']['194'])){
  74. $list['192']['list']['194']['isred'] = 1;
  75. if(isset($list['192'])){
  76. $list['192']['isred'] = 1;
  77. }
  78. }
  79. }
  80. $appropriation = Db::name("appropriation")->where(["status" => 1, "entrust_unit" => get_login_admin("unit_name")])->count();
  81. if ($appropriation !== 0) {
  82. // $list['160']['isred'] = 1;
  83. // $list['160']['list']['195']['isred'] = 1;
  84. if(isset($list['378']['list']['379'])){
  85. $list['378']['list']['379']['isred'] = 1;
  86. if(isset($list['378'])){
  87. $list['378']['isred'] = 1;
  88. }
  89. }
  90. }
  91. } else if ($admin['user_type'] == 2) {
  92. if ($red) {
  93. foreach ($red as $key => $value) {
  94. if ($value['detail'] == 1 || $value['comment'] == 1 || $value['record'] == 1 || $value['user'] == 1 || $value['contact'] == 1) {
  95. array_push($isreds, 1);
  96. } else {
  97. array_push($isreds, 0);
  98. }
  99. }
  100. }
  101. $daijie = Db::name("cost_project")->where(["project_status" => 3,"review_unit"=>get_login_admin("unit_name")])->count();
  102. if ($daijie !== 0) {
  103. if(isset($list['160']['list']['195'])){
  104. $list['160']['list']['195']['isred'] = 1;
  105. if(isset($list['160'])){
  106. $list['160']['isred'] = 1;
  107. }
  108. }
  109. }
  110. $daishen = Db::name("project_audit")->where(["audit_status" => 1, "approver" => $admin['id']])->count();
  111. if ($daishen !== 0) {
  112. // $list['160']['isred'] = 1;
  113. // $list['160']['list']['195']['isred'] = 1;
  114. if(isset($list['160']['list']['401'])){
  115. $list['160']['list']['401']['isred'] = 1;
  116. if(isset($list['160'])){
  117. $list['160']['isred'] = 1;
  118. }
  119. }
  120. }
  121. }
  122. if (in_array(1, $isreds)) {
  123. $isred = 1;
  124. if (array_key_exists(160, $list)) {
  125. if(isset($list['160']['list']['161'])){
  126. $list['160']['list']['161']['isred'] = 1;
  127. if(isset($list['160'])){
  128. $list['160']['isred'] = 1;
  129. }
  130. }
  131. } else if (array_key_exists(192, $list)) {
  132. if(isset($list['192']['list']['234'])){
  133. $list['192']['list']['234']['isred'] = 1;
  134. if(isset($list['192'])){
  135. $list['192']['isred'] = 1;
  136. }
  137. }
  138. }
  139. } else {
  140. $isred = 0;
  141. }
  142. if (get_login_admin('user_type') == -1) {
  143. foreach ($list as $key => $value) {
  144. if (in_array($value['title'], $this->config)) {
  145. unset($list[$key]);
  146. }
  147. }
  148. }
  149. View::assign('unit_name', $unit_name);
  150. View::assign('theme', $theme);
  151. View::assign('menu', $list);
  152. View::assign("type",$type);
  153. View::assign('red',$red);
  154. $count = 0;
  155. $unread_ids = Db::name("admin")->where("id",get_login_admin("id"))->value('unread');
  156. if($unread_ids){
  157. $unread_ids = explode(',',$unread_ids);
  158. $unread = Db::name('project_msg')->whereIn("id",$unread_ids)->select();
  159. $count = count($unread);
  160. View::assign("unread",$unread);
  161. }
  162. View::assign('count',$count);
  163. return View();
  164. }
  165. public function main()
  166. {
  167. $sent_review_amount = Db::name("cost_project")->where([
  168. ["entrust_unit", "=", get_login_admin("unit_name")],
  169. ['delete_time', '=', 0],
  170. ["project_status", ">", 2],
  171. ["project_status", "<>", 9],
  172. ])->field("sent_review_amount,sent_review_cost,review_add_reduce_rate,authorize_amount,engineering_type1")->select();
  173. //engineering_type1=1是预算,2是结算
  174. $amount = [
  175. //送审总额
  176. 'sent_review_amount' => 0,
  177. //评审服务费
  178. 'sent_review_cost' => 0,
  179. //审定总额
  180. 'authorize_amount' => 0,
  181. //总审减率
  182. 'review_add_reduce_rate' => 0
  183. ];
  184. $sent_review_amount_tol = [
  185. "sent_review_amount_type1" => 0,
  186. "sent_review_amount_type2" => 0,
  187. "authorize_amount_type1" => 0,
  188. "authorize_amount_type2" => 0,
  189. "review_add_reduce_rate_type1" => 0,
  190. "review_add_reduce_rate_type2" => 0
  191. ];
  192. for ($i = 0; $i < count($sent_review_amount); $i++) {
  193. $a = $sent_review_amount[$i];
  194. if ($a['engineering_type1'] == 1) {
  195. if ((int)$a["sent_review_amount"]) {
  196. //预算总额
  197. $sent_review_amount_tol["sent_review_amount_type1"] += $a["sent_review_amount"];
  198. }
  199. if ((int)$a["authorize_amount"]) {
  200. //审定
  201. $sent_review_amount_tol["authorize_amount_type1"] += $a["authorize_amount"];
  202. }
  203. } elseif ($a['engineering_type1'] == 2) {
  204. if ((int)$a["sent_review_amount"]) {
  205. //结算总额
  206. $sent_review_amount_tol["sent_review_amount_type2"] += $a["sent_review_amount"];
  207. }
  208. if ((int)$a["authorize_amount"]) {
  209. //审定
  210. $sent_review_amount_tol["authorize_amount_type2"] += $a["authorize_amount"];
  211. }
  212. }
  213. }
  214. //什么率的
  215. $sentReviewAmount = 0;
  216. $authorizeAmount = 0;
  217. $sent_review_amount_type1 = 0;
  218. $authorize_amount_type1 = 0;
  219. $sent_review_amount_type2 = 0;
  220. $authorize_amount_type2 = 0;
  221. for ($i = 0; $i < count($sent_review_amount); $i++) {
  222. $a = $sent_review_amount[$i];
  223. if ($a['engineering_type1'] == 1 && (int)$a["authorize_amount"]) {
  224. if ((int)$a["sent_review_amount"]) {
  225. //预算总额
  226. $sent_review_amount_type1 += $a["sent_review_amount"];
  227. //审定
  228. $authorize_amount_type1 += $a["authorize_amount"];
  229. }
  230. } elseif ($a['engineering_type1'] == 2) {
  231. if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) {
  232. //结算总额
  233. $sent_review_amount_type2 += $a["sent_review_amount"];
  234. //审定
  235. $authorize_amount_type2 += $a["authorize_amount"];
  236. }
  237. }
  238. if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) {
  239. //结算总额
  240. $sentReviewAmount += $a["sent_review_amount"];
  241. //审定
  242. $authorizeAmount += $a["authorize_amount"];
  243. }
  244. }
  245. if ((int)$sent_review_amount_type1 && (int)$authorize_amount_type1) {
  246. //预算核增减率
  247. $sent_review_amount_tol["review_add_reduce_rate_type1"] = sprintf("%.4f", ($authorize_amount_type1 - $sent_review_amount_type1) / $sent_review_amount_type1) * 100;
  248. }
  249. if ($sent_review_amount_type2 && $authorize_amount_type2) {
  250. //结算核增减率
  251. $sent_review_amount_tol["review_add_reduce_rate_type2"] = sprintf("%.4f", ($authorize_amount_type2 - $sent_review_amount_type2) / $sent_review_amount_type2) * 100;
  252. }
  253. if ((int)$sentReviewAmount && (int)$authorizeAmount) {
  254. $amount['review_add_reduce_rate'] = (sprintf("%.4f", ($authorizeAmount - $sentReviewAmount) / $sentReviewAmount)) * 100;
  255. }
  256. for ($i = 0; $i < count($sent_review_amount); $i++) {
  257. $a = $sent_review_amount[$i];
  258. if ((int)$a['sent_review_amount']) {
  259. $amount["sent_review_amount"] += $a['sent_review_amount'];
  260. }
  261. if ((int)$a['sent_review_cost']) {
  262. $amount["sent_review_cost"] += $a['sent_review_cost'];
  263. }
  264. if ((int)$a['authorize_amount']) {
  265. $amount["authorize_amount"] += $a['authorize_amount'];
  266. }
  267. }
  268. //评审服务费,上半年服务费用,下半年服务费用 start
  269. $currentTime = time();
  270. $year = date('Y', $currentTime);
  271. // 计算上半年时间范围
  272. $firstHalfStart = strtotime($year . '-01-01');
  273. $firstHalfEnd = strtotime($year . '-06-30 23:59:59');
  274. // 计算下半年时间范围
  275. $secondHalfStart = strtotime($year . '-07-01');
  276. $secondHalfEnd = strtotime($year . '-12-31 23:59:59');
  277. $first_sent_review_cost = Db::name("cost_project")->where([
  278. ['delete_time', '=', 0],
  279. ["project_status", ">", 2],
  280. ["project_status", "<>", 9],
  281. ["entrust_unit", "=", get_login_admin("unit_name")]
  282. ])->
  283. whereBetween('create_time', [$firstHalfStart, $firstHalfEnd])->field("sent_review_cost")->select()->toArray();
  284. $second_sent_review_cost = Db::name("cost_project")->where([
  285. ['delete_time', '=', 0],
  286. ["project_status", ">", 2],
  287. ["project_status", "<>", 9],
  288. ["entrust_unit", "=", get_login_admin("unit_name")]
  289. ])->whereBetween('create_time', [$secondHalfStart, $secondHalfEnd])->field("sent_review_cost")->select()->toArray();
  290. $sent_review_cost = [
  291. 'first_sent_review_cost' => 0,
  292. 'second_sent_review_cost' => 0
  293. ];
  294. for ($i = 0; $i < count($first_sent_review_cost); $i++) {
  295. $a = $first_sent_review_cost[$i];
  296. $sent_review_cost["first_sent_review_cost"] += $a['sent_review_cost'];
  297. }
  298. for ($i = 0; $i < count($second_sent_review_cost); $i++) {
  299. $a = $second_sent_review_cost[$i];
  300. $sent_review_cost["second_sent_review_cost"] += $a['sent_review_cost'];
  301. }
  302. //评审服务费,上半年服务费用,下半年服务费用 end
  303. //项目数量,正在作业,已归档
  304. $num = Db::name("cost_project")->where([
  305. ["entrust_unit", "=", get_login_admin("unit_name")],
  306. ['delete_time', '=', 0],
  307. ["project_status", '>', 0],
  308. ])->count();
  309. $where = [
  310. ["entrust_unit", "=", get_login_admin("unit_name")],
  311. ['delete_time', '=', 0],
  312. ["project_status", '>', 0],
  313. ];
  314. $data = Db::name("cost_project")->where($where)->select();
  315. $num_project = [
  316. 'num' => 0,
  317. "yu" => 0,
  318. "jie" => 0,
  319. "zuo" => 0,
  320. "gui" => 0,
  321. "tui" => 0,
  322. ];
  323. foreach ($data as $key => $value) {
  324. $num_project["num"] += 1;
  325. if ($value["project_status"] < 6 && $value["project_status"] > 3) {
  326. $num_project["zuo"] += 1;
  327. }
  328. if ($value["project_status"] < 8 && $value["project_status"] > 3) {
  329. if ($value["engineering_type1"] == 1) {
  330. $num_project["yu"] += 1;
  331. }
  332. if ($value["engineering_type1"] == 2) {
  333. $num_project["jie"] += 1;
  334. }
  335. }
  336. if ($value["project_status"] == 8) {
  337. $num_project["gui"] += 1;
  338. }
  339. if ($value["project_status"] == 9) {
  340. $num_project["tui"] += 1;
  341. }
  342. }
  343. //项目数量,正在作业,已归档
  344. $sent_review_cost_real = [];
  345. foreach ($sent_review_cost as $item=>$value){
  346. $sent_review_cost_real[$item] = number_format($value/10000,2,".","");
  347. }
  348. $sent_review_amount_tol_real = [];
  349. foreach ($sent_review_amount_tol as $item=>$value){
  350. if(!($item == "review_add_reduce_rate_type1" || $item == "review_add_reduce_rate_type2")){
  351. $sent_review_amount_tol_real[$item] = number_format($value/10000,2,".","");
  352. }else{
  353. $sent_review_amount_tol_real[$item] = number_format($value,2,".","");
  354. }
  355. }
  356. $amount_real = [];
  357. foreach ($amount as $item=>$value){
  358. if($item=="review_add_reduce_rate"){
  359. $amount_real[$item] = number_format($value,2,".","");
  360. }else{
  361. $amount_real[$item] = number_format($value/10000,2,".","");
  362. }
  363. }
  364. View::assign("sent_review_cost", $sent_review_cost_real);
  365. View::assign("amount", $amount_real);
  366. View::assign("num", $num);
  367. View::assign("num_project", $num_project);
  368. View::assign("sent_review_amount_tol", $sent_review_amount_tol_real);
  369. // dump(self::getHomeFive());
  370. View::assign("home_five", self::getHomeFive());
  371. return View();
  372. }
  373. public function main_company()
  374. {
  375. $sent_review_amount = Db::name("cost_project")->where([
  376. ["review_unit", "=", get_login_admin("unit_name")],
  377. ['delete_time', '=', 0],
  378. ['project_status', '>', 3],
  379. ["project_status", "<>", 7],
  380. ["project_status", "<>", 9],
  381. ])->field("sent_review_amount,sent_review_cost,review_add_reduce_rate,authorize_amount,engineering_type1")->select();
  382. //engineering_type1=1是预算,2是结算
  383. $amount = [
  384. //送审总额
  385. 'sent_review_amount' => 0,
  386. //评审服务费
  387. 'sent_review_cost' => 0,
  388. //审定总额
  389. 'authorize_amount' => 0,
  390. //总审减率
  391. 'review_add_reduce_rate' => 0
  392. ];
  393. $sent_review_amount_tol = [
  394. "sent_review_amount_type1" => 0,
  395. "sent_review_amount_type2" => 0,
  396. "authorize_amount_type1" => 0,
  397. "authorize_amount_type2" => 0,
  398. "review_add_reduce_rate_type1" => 0,
  399. "review_add_reduce_rate_type2" => 0
  400. ];
  401. for ($i = 0; $i < count($sent_review_amount); $i++) {
  402. $a = $sent_review_amount[$i];
  403. if ($a['engineering_type1'] == 1) {
  404. if ((int)$a["sent_review_amount"]) {
  405. //预算总额
  406. $sent_review_amount_tol["sent_review_amount_type1"] += $a["sent_review_amount"];
  407. }
  408. if ((int)$a["authorize_amount"]) {
  409. //审定
  410. $sent_review_amount_tol["authorize_amount_type1"] += $a["authorize_amount"];
  411. }
  412. } elseif ($a['engineering_type1'] == 2) {
  413. if ((int)$a["sent_review_amount"]) {
  414. //结算总额
  415. $sent_review_amount_tol["sent_review_amount_type2"] += $a["sent_review_amount"];
  416. }
  417. if ((int)$a["authorize_amount"]) {
  418. //审定
  419. $sent_review_amount_tol["authorize_amount_type2"] += $a["authorize_amount"];
  420. }
  421. }
  422. }
  423. //什么率的
  424. $sentReviewAmount = 0;
  425. $authorizeAmount = 0;
  426. $sent_review_amount_type1 = 0;
  427. $authorize_amount_type1 = 0;
  428. $sent_review_amount_type2 = 0;
  429. $authorize_amount_type2 = 0;
  430. for ($i = 0; $i < count($sent_review_amount); $i++) {
  431. $a = $sent_review_amount[$i];
  432. if ($a['engineering_type1'] == 1 && (int)$a["authorize_amount"]) {
  433. if ((int)$a["sent_review_amount"]) {
  434. //预算总额
  435. $sent_review_amount_type1 += $a["sent_review_amount"];
  436. //审定
  437. $authorize_amount_type1 += $a["authorize_amount"];
  438. }
  439. } elseif ($a['engineering_type1'] == 2) {
  440. if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) {
  441. //结算总额
  442. $sent_review_amount_type2 += $a["sent_review_amount"];
  443. //审定
  444. $authorize_amount_type2 += $a["authorize_amount"];
  445. }
  446. }
  447. if ((int)$a["sent_review_amount"] && (int)$a["authorize_amount"]) {
  448. //结算总额
  449. $sentReviewAmount += $a["sent_review_amount"];
  450. //审定
  451. $authorizeAmount += $a["authorize_amount"];
  452. }
  453. }
  454. if ((int)$sent_review_amount_type1 && (int)$authorize_amount_type1) {
  455. //预算核增减率
  456. $sent_review_amount_tol["review_add_reduce_rate_type1"] = sprintf("%.4f", ($authorize_amount_type1 - $sent_review_amount_type1) / $sent_review_amount_type1) * 100;
  457. }
  458. if ($sent_review_amount_type2 && $authorize_amount_type2) {
  459. //结算核增减率
  460. $sent_review_amount_tol["review_add_reduce_rate_type2"] = sprintf("%.4f", ($authorize_amount_type2 - $sent_review_amount_type2) / $sent_review_amount_type2) * 100;
  461. }
  462. if ((int)$sentReviewAmount && (int)$authorizeAmount) {
  463. $amount['review_add_reduce_rate'] = (sprintf("%.4f", ($authorizeAmount - $sentReviewAmount) / $sentReviewAmount)) * 100;
  464. }
  465. for ($i = 0; $i < count($sent_review_amount); $i++) {
  466. $a = $sent_review_amount[$i];
  467. if ((int)$a['sent_review_amount']) {
  468. $amount["sent_review_amount"] += $a['sent_review_amount'];
  469. }
  470. if ((int)$a['sent_review_cost']) {
  471. $amount["sent_review_cost"] += $a['sent_review_cost'];
  472. }
  473. if ((int)$a['authorize_amount']) {
  474. $amount["authorize_amount"] += $a['authorize_amount'];
  475. }
  476. }
  477. //评审服务费,上半年服务费用,下半年服务费用 start
  478. $currentTime = time();
  479. $year = date('Y', $currentTime);
  480. // 计算上半年时间范围
  481. $firstHalfStart = strtotime($year . '-01-01');
  482. $firstHalfEnd = strtotime($year . '-06-30 23:59:59');
  483. // 计算下半年时间范围
  484. $secondHalfStart = strtotime($year . '-07-01');
  485. $secondHalfEnd = strtotime($year . '-12-31 23:59:59');
  486. $first_sent_review_cost = Db::name("cost_project")->where([
  487. ['project_status', '>', 3],
  488. ["review_unit", "=", get_login_admin("unit_name")],
  489. ["project_status", "<>", 7],
  490. ["project_status", "<>", 9]
  491. ])->whereBetween('create_time', [$firstHalfStart, $firstHalfEnd])->field("sent_review_cost")->select()->toArray();
  492. $second_sent_review_cost = Db::name("cost_project")->where([
  493. ['project_status', '>', 3],
  494. ["review_unit", "=", get_login_admin("unit_name")],
  495. ["project_status", "<>", 7],
  496. ["project_status", "<>", 9]
  497. ])->whereBetween('create_time', [$secondHalfStart, $secondHalfEnd])->field("sent_review_cost")->select()->toArray();
  498. $sent_review_cost = [
  499. 'first_sent_review_cost' => 0,
  500. 'second_sent_review_cost' => 0
  501. ];
  502. for ($i = 0; $i < count($first_sent_review_cost); $i++) {
  503. $a = $first_sent_review_cost[$i];
  504. $sent_review_cost["first_sent_review_cost"] += $a['sent_review_cost'];
  505. }
  506. for ($i = 0; $i < count($second_sent_review_cost); $i++) {
  507. $a = $second_sent_review_cost[$i];
  508. $sent_review_cost["second_sent_review_cost"] += $a['sent_review_cost'];
  509. }
  510. //评审服务费,上半年服务费用,下半年服务费用 end
  511. //项目数量,正在作业,已归档
  512. $num = Db::name("cost_project")->where([
  513. ["review_unit", "=", get_login_admin("unit_name")],
  514. ['delete_time', '=', 0],
  515. ["project_status", '>', 3],
  516. ])->count();
  517. $where = [
  518. ["review_unit", "=", get_login_admin("unit_name")],
  519. ['delete_time', '=', 0],
  520. ["project_status", '>', 2],
  521. ];
  522. $data = Db::name("cost_project")->where($where)->select();
  523. $num_project = [
  524. 'num' => 0,
  525. "yu" => 0,
  526. "jie" => 0,
  527. "zuo" => 0,
  528. "gui" => 0,
  529. "tui" => 0,
  530. ];
  531. foreach ($data as $key => $value) {
  532. $num_project["num"] += 1;
  533. if ($value["project_status"] < 6 && $value["project_status"] > 3) {
  534. $num_project["zuo"] += 1;
  535. }
  536. if ($value["project_status"] < 8 && $value["project_status"] > 3) {
  537. if ($value["engineering_type1"] == 1) {
  538. $num_project["yu"] += 1;
  539. }
  540. if ($value["engineering_type1"] == 2) {
  541. $num_project["jie"] += 1;
  542. }
  543. }
  544. if ($value["project_status"] == 8) {
  545. $num_project["gui"] += 1;
  546. }
  547. if ($value["project_status"] == 9) {
  548. $num_project["tui"] += 1;
  549. }
  550. }
  551. //项目数量,正在作业,已归档
  552. $sent_review_cost_real = [];
  553. foreach ($sent_review_cost as $item=>$value){
  554. $sent_review_cost_real[$item] = number_format($value/10000,2,".","");
  555. }
  556. $sent_review_amount_tol_real = [];
  557. foreach ($sent_review_amount_tol as $item=>$value){
  558. if(!($item == "review_add_reduce_rate_type1" || $item == "review_add_reduce_rate_type2")){
  559. $sent_review_amount_tol_real[$item] = number_format($value/10000,2,".","");
  560. }else{
  561. $sent_review_amount_tol_real[$item] = number_format($value,2,".","");
  562. }
  563. }
  564. $amount_real = [];
  565. foreach ($amount as $item=>$value){
  566. if($item=="review_add_reduce_rate"){
  567. $amount_real[$item] = number_format($value,2,".","");
  568. }else{
  569. $amount_real[$item] = number_format($value/10000,2,".","");
  570. }
  571. }
  572. View::assign("sent_review_cost", $sent_review_cost_real);
  573. View::assign("amount", $amount_real);
  574. View::assign("num", $num);
  575. View::assign("num_project", $num_project);
  576. View::assign("sent_review_amount_tol", $sent_review_amount_tol_real);
  577. View::assign("home_five", self::getHomeFive_company());
  578. return View();
  579. }
  580. public function main_admin()
  581. {
  582. return View();
  583. }
  584. //设置theme
  585. public function set_theme()
  586. {
  587. if (request()->isAjax()) {
  588. $param = get_params();
  589. $admin = get_login_admin();
  590. Db::name('Admin')->where('id', $admin['id'])->update(['theme' => $param['theme']]);
  591. return to_assign();
  592. } else {
  593. return to_assign(1, '操作错误');
  594. }
  595. }
  596. public function head()
  597. {
  598. $param = get_params();
  599. // halt($param);
  600. $where = [];
  601. if(!empty($param["nickname"])){
  602. $where = [["a.nickname","like","%".$param["nickname"]."%"]];
  603. }
  604. $list = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
  605. ->where([["d.type", "=", 2], ["pid", "=", 0], ["d.status", "=", 1]])->where($where)->field("d.id,d.title,a.nickname,a.mobile,a.email")->select();
  606. $datalist = [
  607. "code" => 0,
  608. "count" => count($list),
  609. "data" => $list
  610. ];
  611. return json($datalist);
  612. }
  613. public function cp_head(){
  614. $param = get_params();
  615. $where = [];
  616. if (!empty($param["nickname"])) {
  617. $where = [["a.nickname|d.title", "like", "%" . $param["nickname"] . "%"]];
  618. }
  619. $list_entrust = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
  620. ->where([["d.type", "=", 0], ["pid", "=", 0], ["d.status", "=", 1]])
  621. ->where($where)
  622. ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
  623. ->select()->toArray();
  624. $list_proprietor = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
  625. ->where([["d.type", "=", 1], ["pid", "=", 0], ["d.status", "=", 1]])
  626. ->where($where)
  627. ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
  628. ->select()->toArray();
  629. $list_exterior = array_merge($list_proprietor,$list_entrust);
  630. $datalist = [
  631. "code" => 0,
  632. "count" => count($list_exterior),
  633. "data" => $list_exterior
  634. ];
  635. return json($datalist);
  636. }
  637. public function cp_people(){
  638. $list = Db::name("admin")->alias("a")->where("a.unit_name",get_login_admin("unit_name"))
  639. ->join("department d","a.did=d.id","left")
  640. ->field("a.id,d.title,a.nickname,a.mobile,a.email")->select();
  641. $datalist = [
  642. "code" => 0,
  643. "count" => count($list),
  644. "data" => $list
  645. ];
  646. return json($datalist);
  647. }
  648. /**
  649. * 公司通讯录
  650. */
  651. public function people(){
  652. $p = get_params();
  653. $where = array();
  654. if (!empty($p['nickname'])) {
  655. $where[] = ['a.nickname', 'like', "%".$p['nickname']."%"];
  656. }
  657. $list = Db::name('admin')->where("a.unit_name",get_login_admin("unit_name"))->alias('a')
  658. ->join("department d","a.unit_name=d.id","left")
  659. ->field("a.*,d.title")->where("a.status",1)
  660. ->where($where)
  661. ->select();
  662. $datalist = [
  663. "code" => 0,
  664. "count" => count($list),
  665. "data" => $list
  666. ];
  667. return json($datalist);
  668. }
  669. public function getHomeFive()
  670. {
  671. $where = [
  672. ['name', '=', '待审核任务'],
  673. ['name', '=', '临期项目-财政局'],
  674. ['name', '=', '逾期项目-财政局'],
  675. ['name', '=', '项目列表-财政局'],
  676. ['name', '=', '通讯录-财政局'],
  677. ];
  678. $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
  679. $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
  680. $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
  681. $login_rules = explode(',', $login_rules);
  682. $rules_id = array();
  683. foreach ($list as $key => $value) {
  684. if ($value['name'] == "待审核任务") {
  685. if (in_array($value['id'], $login_rules)) {
  686. $rules_id['audit_project'] = 1;
  687. } else {
  688. $rules_id['audit_project'] = 0;
  689. }
  690. } else if ($value['name'] == "临期项目-财政局") {
  691. if (in_array($value['id'], $login_rules)) {
  692. $rules_id['imminent_project'] = 1;
  693. } else {
  694. $rules_id['imminent_project'] = 0;
  695. }
  696. } else if ($value['name'] == "逾期项目-财政局") {
  697. if (in_array($value['id'], $login_rules)) {
  698. $rules_id['overdue_item'] = 1;
  699. } else {
  700. $rules_id['overdue_item'] = 0;
  701. }
  702. } else if ($value['name'] == "项目列表-财政局") {
  703. if (in_array($value['id'], $login_rules)) {
  704. $rules_id['list_project'] = 1;
  705. } else {
  706. $rules_id['list_project'] = 0;
  707. }
  708. } else if ($value['name'] == "通讯录-财政局") {
  709. if (in_array($value['id'], $login_rules)) {
  710. $rules_id['address_book'] = 1;
  711. } else {
  712. $rules_id['address_book'] = 0;
  713. }
  714. }
  715. }
  716. return $rules_id;
  717. }
  718. public function getHomeFive_company()
  719. {
  720. $where = [
  721. ['name', '=', '待接收项目_公司首页'],
  722. ['name', '=', '临期项目-公司'],
  723. ['name', '=', '逾期项目-公司'],
  724. ['name', '=', '项目列表-公司'],
  725. ['name', '=', '通讯录-公司'],
  726. ];
  727. $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
  728. // halt($list);
  729. $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
  730. $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
  731. $login_rules = explode(',', $login_rules);
  732. // halt($login_rules);
  733. $rules_id = array();
  734. foreach ($list as $key => $value) {
  735. if ($value['name'] == "待接收项目_公司首页") {
  736. if (in_array($value['id'], $login_rules)) {
  737. $rules_id['audit_project'] = 1;
  738. } else {
  739. $rules_id['audit_project'] = 0;
  740. }
  741. } else if ($value['name'] == "临期项目-公司") {
  742. if (in_array($value['id'], $login_rules)) {
  743. $rules_id['imminent_project'] = 1;
  744. } else {
  745. $rules_id['imminent_project'] = 0;
  746. }
  747. } else if ($value['name'] == "逾期项目-公司") {
  748. if (in_array($value['id'], $login_rules)) {
  749. $rules_id['overdue_item'] = 1;
  750. } else {
  751. $rules_id['overdue_item'] = 0;
  752. }
  753. } else if ($value['name'] == "项目列表-公司") {
  754. if (in_array($value['id'], $login_rules)) {
  755. $rules_id['list_project'] = 1;
  756. } else {
  757. $rules_id['list_project'] = 0;
  758. }
  759. } else if ($value['name'] == "通讯录-公司") {
  760. if (in_array($value['id'], $login_rules)) {
  761. $rules_id['address_book'] = 1;
  762. } else {
  763. $rules_id['address_book'] = 0;
  764. }
  765. }
  766. }
  767. // halt($rules_id);
  768. return $rules_id;
  769. }
  770. }