Temporary.php 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\mobile\controller;
  4. use app\admin\BaseController;
  5. use app\admin\controller\field\Field;
  6. use app\admin\model\Admin;
  7. use app\admin\model\Admin as AdminList;
  8. use app\admin\model\Appointment as AppointmentModel;
  9. use app\admin\model\Contact;
  10. use app\admin\model\Contact as ContactModel;
  11. use app\admin\model\CostProject as CostProjectModel;
  12. use app\admin\model\ProjectAudit as AuditModel;
  13. use app\admin\model\ProjectRecord;
  14. use think\App;
  15. use think\facade\Db;
  16. use think\facade\Request;
  17. use think\facade\Session;
  18. use think\facade\View;
  19. use app\admin\model\Appropriation as AppropriationModel;
  20. use app\admin\controller\datastat\Datastat;
  21. class Temporary extends BaseController
  22. {
  23. /**
  24. * 构造函数
  25. */
  26. public function __construct(App $app)
  27. {
  28. $this->Datastat = new Datastat($app);
  29. $this->AppropriationModel = new AppropriationModel();
  30. $this->Field = new Field($app);
  31. $this->model = new CostProjectModel();
  32. $this->Adminmodel = new Admin();
  33. $this->Auditmodel = new AuditModel();
  34. $this->ContactModel = new ContactModel();
  35. $this->AppointmentModel = new AppointmentModel();
  36. $this->uid = get_login_admin('id');
  37. $this->unit = get_login_admin('unit_name');
  38. $this->user_tpe = Db::name("department")->where("id", $this->unit)->value("type");
  39. // $session_admin = get_config('app.session_admin');
  40. // $request = Request::instance();
  41. // if (!Session::has($session_admin) && $request->url() !== '/mobile/index/login.html') {
  42. // redirect('/mobile/index/login.html')->send();
  43. // exit;
  44. // }
  45. }
  46. public function getOpenId() {
  47. $redirect_uri = "http://testwxpress.ngrok.natapp.cn/index.php/Home/Index/getCode";
  48. $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . C('WECHAT_APPID') . '&redirect_uri=' . urlencode($redirect_uri) . '&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect';
  49. header("Location:" . $url);
  50. }
  51. /**
  52. *个人资料
  53. */
  54. public function person()
  55. {
  56. $person = get_login_admin();
  57. $red = $this->Auditmodel->where("approver", $this->uid)->where("audit_status", 1)->count();
  58. $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
  59. $red_kan = 0;
  60. foreach ($red_id as $item => $value) {
  61. if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
  62. $red_kan = 1;
  63. }
  64. }
  65. View::assign("red_kan", $red_kan);
  66. View::assign('red', $red);
  67. View::assign('person', $person);
  68. return view();
  69. }
  70. /**
  71. * cp看板内容
  72. */
  73. public function detail()
  74. {
  75. $param = get_params();
  76. $id = isset($param['id']) ? $param['id'] : 0;
  77. $type = isset($param['type']) ? $param['type'] : 0;
  78. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  79. $order = empty($param['order']) ? 'a.id desc' : $param['order'];
  80. $detail = $this->model->getCostProjectById($id);
  81. $comment = Db::name("project_comment")->where("project_id", $id)->order('create_time', 'desc')->select();
  82. $file_array = Db::name('ProjectFile')
  83. ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
  84. ->alias('mf')
  85. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  86. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  87. ->order('mf.create_time desc')
  88. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  89. ->select()->toArray();
  90. $report = Db::name("project_report")
  91. ->where([["project_id", "=", $id]])
  92. ->alias("r")->join("admin a", "r.maker_id = a.id")
  93. ->field("r.*,a.nickname")
  94. ->select();
  95. $contact = $this->ContactModel->where([['project_id', '=', $id]])
  96. ->field('a.*,u.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id')
  97. ->alias('a')
  98. ->join('file f', "a.file = f.id", "left")
  99. ->join('Admin u', 'a.maker_id = u.id', "left")
  100. ->order($order)
  101. ->paginate(9999, false, ['query' => $param])
  102. ->each(function ($item, $key) {
  103. })->toArray();
  104. $contact = $contact['data'];
  105. $where = [
  106. ["cp_project_record.delete_time", "=", 0],
  107. ["project_id", "=", $id],
  108. ["maker_id", "=", get_login_admin('id')]
  109. ];
  110. $record = Db::name('project_record')->where($where)
  111. ->field('a.*,u.nickname as admin_name')
  112. ->alias('a')
  113. ->join('Admin u', 'a.maker_id = u.id', "left")
  114. ->order($order)
  115. ->select();
  116. //2是公司,0是财政局,1是业主
  117. $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
  118. if ($unit_type == 0) {
  119. $person = self::user($id);
  120. View::assign('project_five', self::getProjectFive());
  121. } elseif ($unit_type == 2) {
  122. $person = self::user($id);
  123. View::assign('project_five', self::getProjectFiveCompany());
  124. } else {
  125. $person = 0;
  126. View::assign('project_five', self::getProjectFiveYezhu());
  127. }
  128. $appropriation_uid = Db::name("appropriation_project")->where("project_id", $id)->value("uid");
  129. if (empty($appropriation_uid)) {
  130. $appropriation_data = [];
  131. $appropriation_file_array = [];
  132. } else {
  133. $where = [
  134. ["id", "=", $appropriation_uid],
  135. ["status", ">", 0]
  136. ];
  137. //请款
  138. $appropriation = Db::name("appropriation")->where($where)->find();
  139. if (!empty($appropriation)) {
  140. $projects = Db::name("appropriation_project")->alias("a")
  141. ->leftJoin("cost_project c", "a.project_id=c.id")
  142. ->where("uid", $appropriation["id"])->column("c.project_name,c.sent_review_cost");
  143. $data = [];
  144. $appropriation_amount = 0;
  145. for ($i = 0; $i < count($projects); $i++) {
  146. $v = $projects[$i];
  147. $b = $i + 1;
  148. $appropriation_amount += $v["sent_review_cost"];
  149. $data[] = $b . "." . $v["project_name"];
  150. }
  151. $appropriation_data = $appropriation;
  152. $appropriation_data["appropriation_amount"] = $appropriation_amount;
  153. $appropriation_data["project_name"] = $data;
  154. $appropriation_file_array = Db::name('ProjectFile')
  155. ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
  156. ->alias('mf')
  157. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  158. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  159. ->order('mf.create_time desc')
  160. ->where(array('mf.topic_id' => $appropriation_uid, 'mf.module' => 'appropriation'))
  161. ->select()->toArray();
  162. } else {
  163. $appropriation_data = [];
  164. $appropriation_file_array = [];
  165. }
  166. }
  167. $project_log = self::project_log($id);
  168. $red = Db::name("new_msg")->where([["uid", '=', $this->uid], ["project_id", "=", $id]])->field('detail,comment,report,user,contact')->find();
  169. if (empty($red)) {
  170. $red = ["detail" => 0, "comment" => 0, "report" => 0, "user" => 0, "contact" => 0];
  171. }
  172. $field = $this->Field->get_field_rules_new($this->uid);
  173. $fields = [];
  174. foreach ($field as $k=>$v){
  175. if($v==1){
  176. $fields[$k] = true;
  177. }else{
  178. $fields[$k] = false;
  179. }
  180. }
  181. if($this->user_tpe==2){
  182. $fields["sent_review_approver_amount"] = false;
  183. $fields["construction_approver_amount"] = false;
  184. }
  185. $appointmentList = $this->AppointmentModel->where("project_id",$id)->paginate(9999, false, ['query' => $param])
  186. ->order("create_time","desc")
  187. ->each(function ($item) {
  188. if($item->sponsor_unit==get_login_admin("unit_name")){
  189. $item->operate = false;
  190. }else{
  191. $item->operate = true;
  192. }
  193. });;
  194. // halt($appointmentList->toArray());
  195. View::assign('field', $fields);
  196. if (!empty($detail)) {
  197. View::assign('appointmentList', $appointmentList);
  198. View::assign('project_log', $project_log);
  199. View::assign('project_id', $id);
  200. View::assign('comment', $comment);
  201. View::assign('record', $record);
  202. View::assign('contact', $contact);
  203. View::assign('detail', $detail);
  204. View::assign('appropriation', $appropriation_data);
  205. View::assign('file_array', $file_array);
  206. View::assign('appropriation_file_array', $appropriation_file_array);
  207. View::assign('report', $report);
  208. View::assign('person', $person);
  209. View::assign('red', $red);
  210. View::assign('unit_type', $unit_type);
  211. return view();
  212. } else {
  213. throw new \think\exception\HttpException(404, '找不到页面');
  214. }
  215. }
  216. /**
  217. * cp代办内容
  218. */
  219. public function pdetail()
  220. {
  221. $param = get_params();
  222. $id = isset($param['id']) ? $param['id'] : 0;
  223. $type = isset($param['type']) ? $param['type'] : 0;
  224. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  225. $order = empty($param['order']) ? 'a.id desc' : $param['order'];
  226. $detail = $this->model->getCostProjectById($id);
  227. $comment = Db::name("project_comment")->where("project_id", $id)->order('create_time', 'desc')->select();
  228. $file_array = Db::name('ProjectFile')
  229. ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
  230. ->alias('mf')
  231. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  232. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  233. ->order('mf.create_time desc')
  234. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  235. ->select()->toArray();
  236. $report = Db::name("project_report")->where([["project_id", "=", $id], ["r.status", "=", 1]])->alias("r")->join("admin a", "r.maker_id = a.id")->field("r.*,a.nickname")->select();
  237. $contact = $this->ContactModel->where([['project_id', '=', $id]])
  238. ->field('a.*,u.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id')
  239. ->alias('a')
  240. ->join('file f', "a.file = f.id", "left")
  241. ->join('Admin u', 'a.maker_id = u.id', "left")
  242. ->order($order)
  243. ->paginate(9999, false, ['query' => $param])
  244. ->each(function ($item, $key) {
  245. })->toArray();
  246. $contact = $contact['data'];
  247. $where = [
  248. ["cp_project_record.delete_time", "=", 0],
  249. ["project_id", "=", $id],
  250. ["maker_id", "=", get_login_admin('id')]
  251. ];
  252. $record = Db::name('project_record')->where($where)
  253. ->field('a.*,u.nickname as admin_name')
  254. ->alias('a')
  255. ->join('Admin u', 'a.maker_id = u.id', "left")
  256. ->order($order)
  257. ->select();
  258. //2是公司,0是财政局,1是业主
  259. $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
  260. if ($unit_type == 0) {
  261. $person = self::user($id);
  262. View::assign('project_five', self::getProjectFive());
  263. } elseif ($unit_type == 2) {
  264. $person = self::user($id);
  265. View::assign('project_five', self::getProjectFiveCompany());
  266. } else {
  267. $person = 0;
  268. View::assign('project_five', self::getProjectFiveYezhu());
  269. }
  270. $field = $this->Field->get_field_rules_new($this->uid);
  271. $fields = [];
  272. foreach ($field as $k=>$v){
  273. if($v==1){
  274. $fields[$k] = true;
  275. }else{
  276. $fields[$k] = false;
  277. }
  278. }
  279. if($this->user_tpe==2){
  280. $fields["sent_review_approver_amount"] = false;
  281. $fields["construction_approver_amount"] = false;
  282. }
  283. View::assign('field', $fields);
  284. $project_log = self::project_log($id);
  285. // halt($detail);
  286. if (!empty($detail)) {
  287. View::assign('project_log', $project_log);
  288. View::assign('project_id', $id);
  289. View::assign('comment', $comment);
  290. View::assign('record', $record);
  291. View::assign('contact', $contact);
  292. View::assign('detail', $detail);
  293. View::assign('file_array', $file_array);
  294. View::assign('report', $report);
  295. View::assign('person', $person);
  296. return view();
  297. } else {
  298. echo '<div style="text-align:center;color:red;margin-top:20%;font-size:425%"><span>项目不存在!</span><br><span>已被删除</span></div>';
  299. // throw new \think\exception\HttpException(404, '项目不存在');
  300. }
  301. }
  302. /**
  303. * cp看板报告内容
  304. */
  305. public function report_detail()
  306. {
  307. $param = get_params();
  308. $id = isset($param['id']) ? $param['id'] : 0;
  309. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  310. $detail = Db::name('ProjectReport')->where(['id' => $id])->find();
  311. if (empty($detail)) {
  312. if (empty($detail)) {
  313. echo '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';
  314. exit;
  315. }
  316. } else {
  317. $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
  318. $detail["maker_name"] = $maker_name;
  319. $file_array = Db::name('ProjectReport')
  320. ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
  321. ->alias('r')
  322. ->join('File f', 'r.file = f.id')
  323. ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
  324. ->order('r.create_time desc')
  325. ->where(array('r.id' => $id))
  326. ->select()->toArray();
  327. View::assign('file_array', $file_array);
  328. View::assign('project_id', $project_id);
  329. View::assign('detail', $detail);
  330. return view();
  331. }
  332. }
  333. /**
  334. * cp待办报告内容
  335. */
  336. public function report_pdetail()
  337. {
  338. $param = get_params();
  339. $id = isset($param['id']) ? $param['id'] : 0;
  340. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  341. $detail = Db::name('ProjectReport')->where(['id' => $id])->find();
  342. if (empty($detail)) {
  343. if (empty($detail)) {
  344. echo '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';
  345. exit;
  346. }
  347. } else {
  348. $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
  349. $detail["maker_name"] = $maker_name;
  350. $file_array = Db::name('ProjectReport')
  351. ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
  352. ->alias('r')
  353. ->join('File f', 'r.file = f.id')
  354. ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
  355. ->order('r.create_time desc')
  356. ->where(array('r.id' => $id))
  357. ->select()->toArray();
  358. View::assign('file_array', $file_array);
  359. View::assign('project_id', $project_id);
  360. View::assign('detail', $detail);
  361. return view();
  362. }
  363. }
  364. /**
  365. *项目日志
  366. */
  367. public function project_log($project_id)
  368. {
  369. // $project_id = 24;
  370. $login_admin = get_login_admin();
  371. $where = array();
  372. if ($login_admin['user_type'] == 2) {
  373. $where = [
  374. ['project_status', '>=', 3],
  375. ['unit_name', '=', $login_admin['unit_name']],
  376. ];
  377. } else {
  378. if ($login_admin['permission'] != 1) {
  379. $where = [
  380. ['unit_name', '=', $login_admin['unit_name']],
  381. ];
  382. }
  383. }
  384. // dump($where);
  385. $project_log = Db::name('ProjectLog')->where($where)->where('project_id', $project_id)->order('create_time', 'desc')->select()->toArray();
  386. foreach ($project_log as $key => $value) {
  387. $project_log[$key]['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
  388. }
  389. // dump($project_log);
  390. // View::assign('project_log', $project_log);
  391. // return View();
  392. return $project_log;
  393. }
  394. /**
  395. *
  396. */
  397. public function sift()
  398. {
  399. return view();
  400. }
  401. /**
  402. *项目人员
  403. */
  404. public function user($id)
  405. {
  406. $ids = $this->model->where("id", $id)->field("entrust_maker,review_head,operate_head,operate_team")->find();
  407. if (empty($ids)) {
  408. return [];
  409. } else {
  410. $ids->toArray();
  411. }
  412. $idarr = $ids["operate_team"] . ',' . $ids["operate_head"] . ',' . $ids["review_head"] . ',' . $ids["entrust_maker"];
  413. $idarr = explode(",", $idarr);
  414. $param = [];
  415. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  416. $list = $this->Adminmodel->whereIn("id", $idarr)->field("id,nickname,unit_name,mobile,email")->paginate(9999, false, ['query' => $param])
  417. // field("a.id,a.nickname,a.unit_name,a.mobile,a.email,d.title,d.type")->join('department d', 'a.unit_name = d.id', 'LEFT')
  418. ->each(function ($item) {
  419. //获取单位的邮箱,单位信息页没做
  420. $item->email = Db::name('department')->where(['id' => $item->unit_name])->value('email');
  421. $type = Db::name('department')->where(['id' => $item->unit_name])->value('type');
  422. $item->unit_name = Db::name('department')->where(['id' => $item->unit_name])->value('title');
  423. // dump($type);
  424. if ($type == 0) {
  425. $item->unit_type = "委托单位";
  426. } elseif ($type == 1) {
  427. $item->unit_type = "送审单位";
  428. } elseif ($type == 2) {
  429. $item->unit_type = "评审机构";
  430. } else {
  431. $item->unit_type = "施工单位";
  432. }
  433. })->toArray();
  434. $list = $list["data"];
  435. $time_id = time();
  436. $shigong = $this->model->where('id', $id)->find();
  437. if ($shigong["construction_unit"] !== null ||
  438. $shigong["construction_head"] !== null ||
  439. $shigong["construction_email"] !== null ||
  440. $shigong["construction_phone"] !== null
  441. ) {
  442. $shigongdata["id"] = $time_id;
  443. $shigongdata["nickname"] = $shigong["construction_unit"];
  444. $shigongdata["unit_name"] = $shigong["construction_head"];
  445. $shigongdata["email"] = $shigong["construction_email"];
  446. $shigongdata["mobile"] = $shigong["construction_phone"];
  447. $shigongdata["unit_type"] = "施工单位";
  448. array_push($list, $shigongdata);
  449. }
  450. $time_id_sent = time() - 200;
  451. if ($shigong["sent_review_unit"] !== null ||
  452. $shigong["sent_review_head"] !== null ||
  453. $shigong["sent_review_phone"] !== null ||
  454. $shigong["sent_review_head_email"] !== null
  455. ) {
  456. $sent_review_data["id"] = $time_id_sent;
  457. $sent_review_data["nickname"] = $shigong["sent_review_head_name"];
  458. $sent_review_data["unit_name"] = $shigong["sent_review_unit_name"];
  459. $sent_review_data["email"] = $shigong["sent_review_head_email"];
  460. $sent_review_data["mobile"] = $shigong["sent_review_phone"];
  461. $sent_review_data["unit_type"] = "送审单位";
  462. array_push($list, $sent_review_data);
  463. }
  464. if (empty($ids['operate_team'])) {
  465. $operate_team[] = '0';
  466. } else {
  467. $operate_team = explode(',', $ids['operate_team']);
  468. }
  469. for ($i = 0; $i < count($list); $i++) {
  470. if ($list[$i]['id'] == $ids['entrust_maker']) {
  471. // dump($list[$i]['id'],$ids['entrust_maker']);
  472. $list[$i]["type"] = 1;
  473. } elseif ($list[$i]['id'] == $ids['review_head']) {
  474. $list[$i]["type"] = 2;
  475. } elseif ($list[$i]['id'] == $ids['operate_head']) {
  476. $list[$i]["type"] = 3;
  477. } elseif (in_array($list[$i]['id'], $operate_team)) {
  478. $list[$i]["type"] = 4;
  479. } elseif ($list[$i]['id'] == $time_id) {
  480. $list[$i]["type"] = 5;
  481. } elseif ($list[$i]['id'] !== time() - 1000) {
  482. $list[$i]["type"] = 6;
  483. }
  484. }
  485. $type = array_column($list, 'type');
  486. array_multisort($type, SORT_ASC, $list);
  487. return $list;
  488. }
  489. /**
  490. * 修改个人资料
  491. */
  492. public function revise()
  493. {
  494. $person = get_login_admin();
  495. View::assign('person', $person);
  496. return view();
  497. }
  498. /**
  499. * 消息通知
  500. * 通用
  501. */
  502. public function notice()
  503. {
  504. $unread_id = Db::name("admin")->where("id", $this->uid)->value("unread");
  505. if (empty($unread_id)) {
  506. $unread_ids = [];
  507. } else {
  508. $unread_ids = explode(",", $unread_id);
  509. }
  510. $list = Db::name("ProjectMsg")->where("uid", $this->uid)->select();
  511. if (is_object($list)) {
  512. $data = $list->toArray();
  513. }
  514. $real_data = [];
  515. foreach ($data as $item => $v) {
  516. if (in_array($v["id"], $unread_ids)) {
  517. $v["red"] = 1;
  518. $real_data[] = $v;
  519. } else {
  520. $v["red"] = 0;
  521. $real_data[] = $v;
  522. }
  523. }
  524. Db::name("admin")->where("id", $this->uid)->update(["unread" => null]);
  525. View::assign("msg", $real_data);
  526. return view();
  527. }
  528. public function notice_content()
  529. {
  530. return view();
  531. }
  532. /**
  533. * 工作记录
  534. */
  535. public function record()
  536. {
  537. $param = get_params();
  538. $id = isset($param['id']) ? $param['id'] : 0;
  539. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  540. $detail = (new ProjectRecord())->detail($id);
  541. if (empty($detail)) {
  542. if (empty($detail)) {
  543. echo '<div style="text-align:center;color:red;margin-top:20%;">该记录不存在</div>';
  544. exit;
  545. }
  546. return '';
  547. }
  548. $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname");
  549. $detail["maker_name"] = $maker_name;
  550. View::assign('detail', $detail);
  551. View::assign('project_id', $project_id);
  552. return view();
  553. }
  554. /**
  555. * 编辑工作记录
  556. */
  557. public function record_edit()
  558. {
  559. $param = get_params();
  560. $id = isset($param['id']) ? $param['id'] : 0;//记录id
  561. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  562. $project = Db::name("cost_project")->where("id", $project_id)->value("project_name");
  563. $detail = (new ProjectRecord())->getRecordById($id);
  564. if (!empty($detail)) {
  565. View::assign('id', $id);
  566. View::assign('user_type', $this->user_tpe);
  567. View::assign('project_id', $project_id);
  568. View::assign('project', $project);
  569. View::assign('detail', $detail);
  570. return view();
  571. } else {
  572. throw new \think\exception\HttpException(404, '页面不存在');
  573. }
  574. }
  575. /**
  576. * 添加工作记录
  577. */
  578. public function record_add()
  579. {
  580. $param = get_params();
  581. $id = isset($param['id']) ? $param['id'] : 0;//记录id
  582. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  583. $project = Db::name("cost_project")->where("id", $project_id)->value("project_name");
  584. View::assign('id', $id);
  585. View::assign('user_type', $this->user_tpe);
  586. View::assign('project_id', $project_id);
  587. View::assign('project', $project);
  588. return view();
  589. }
  590. public function appointment_add()
  591. {
  592. $param = get_params();
  593. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  594. View::assign('user_type', $this->user_tpe);
  595. View::assign('project_id', $project_id);
  596. return view();
  597. }
  598. /**
  599. * 邀请函
  600. */
  601. public function invite()
  602. {
  603. $param = get_params();
  604. $id = isset($param['id']) ? $param['id'] : 0;//记录id
  605. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  606. $project = Db::name("cost_project")->where("id", $project_id)->value("project_name");
  607. $detail = (new Contact())->detail($id);
  608. $file_array = Db::name('contact')
  609. ->field("r.*,a.nickname as admin_name,f.name,f.filesize,f.filepath,f.fileext,f.admin_id")
  610. ->alias('r')
  611. ->join('File f', 'r.file = f.id')
  612. ->join('Admin a', 'r.maker_id = a.id', 'LEFT')
  613. ->order('r.create_time desc')
  614. ->where(array('r.id' => $id))
  615. ->select()->toArray();
  616. if (!empty($detail)) {
  617. View::assign('id', $id);
  618. View::assign('project_id', $project_id);
  619. View::assign('project', $project);
  620. View::assign('detail', $detail);
  621. View::assign('file_array', $file_array);
  622. return view();
  623. } else {
  624. throw new \think\exception\HttpException(404, '页面不存在');
  625. }
  626. }
  627. public function cost_detail()
  628. {
  629. return view();
  630. }
  631. public function login()
  632. {
  633. return view();
  634. }
  635. // cp请款函内容
  636. public function request_detail()
  637. {
  638. $param = get_params();
  639. return view();
  640. }
  641. /**
  642. * 查看审批进度
  643. */
  644. public function progress()
  645. {
  646. $param = get_params();
  647. $id = isset($param['id']) ? $param['id'] : 0;
  648. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  649. $order = empty($param['order']) ? 'id desc' : $param['order'];
  650. $list = $this->Auditmodel->alias('a')->join("cost_project c", "a.project_id=c.id", 'left')
  651. ->field("a.*,c.project_status,c.sent_review_amount,c.engineering_type,c.review_unit_name")->where('else_id', $id)->order('create_time', "sec")
  652. ->select()
  653. ->each(function ($item) {
  654. switch ($item["audit_type"]) {
  655. case 4:
  656. $item->else_name = "报告一级审核";
  657. break;
  658. case 5:
  659. $item->else_name = "报告二级审核";
  660. break;
  661. case 6:
  662. $item->else_name = "报告三级审核";
  663. break;
  664. }
  665. });
  666. View::assign('list', $list);
  667. return view();
  668. }
  669. public function contacts_exterior()
  670. {
  671. $param = get_params();
  672. $where = [];
  673. if (!empty($param["keyword"])) {
  674. $where = [["a.nickname|d.title", "like", "%" . $param["keyword"] . "%"]];
  675. }
  676. //0:财政局;1:业主;2:公司
  677. if ($this->user_tpe == 0) {
  678. //公司负责人
  679. $list_company = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
  680. ->where([["d.type", "=", 2], ["pid", "=", 0], ["d.status", "=", 1]])
  681. ->where($where)->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
  682. ->select()->toArray();
  683. $list_proprietor = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
  684. ->where([["d.type", "=", 1], ["pid", "=", 0], ["d.status", "=", 1]])
  685. ->where($where)
  686. ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
  687. ->select()->toArray();
  688. $list_exterior = array_merge($list_company,$list_proprietor);
  689. } else if ($this->user_tpe == 1) {
  690. //公司负责人
  691. $list_company = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
  692. ->where([["d.type", "=", 2], ["pid", "=", 0], ["d.status", "=", 1]])
  693. ->where($where)->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
  694. ->select()->toArray();
  695. //财评负责人
  696. $list_entrust = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
  697. ->where([["d.type", "=", 0], ["pid", "=", 0], ["d.status", "=", 1]])
  698. ->where($where)
  699. ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
  700. ->select()->toArray();
  701. $list_exterior = array_merge($list_company,$list_entrust);
  702. } else if ($this->user_tpe == 2) {
  703. //公司内部通讯录
  704. $list_entrust = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
  705. ->where([["d.type", "=", 0], ["pid", "=", 0], ["d.status", "=", 1]])
  706. ->where($where)
  707. ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
  708. ->select()->toArray();
  709. $list_proprietor = Db::name('department')->alias('d')->join("admin a", "d.leader_id=a.id")
  710. ->where([["d.type", "=", 1], ["pid", "=", 0], ["d.status", "=", 1]])
  711. ->where($where)
  712. ->field("d.id,d.title,d.type,a.nickname,a.mobile,a.email")
  713. ->select()->toArray();
  714. $list_exterior = array_merge($list_proprietor,$list_entrust);
  715. }
  716. View::assign('list_exterior', $list_exterior);
  717. return view();
  718. }
  719. public function getProjectFive()
  720. {
  721. $where = [
  722. ['name', '=', '作业日志-财政局'],
  723. ['name', '=', '工作记录-财政局'],
  724. ['name', '=', '项目报告-财政局'],
  725. ['name', '=', '项目人员-财政局'],
  726. ['name', '=', '项目动态-财政局'],
  727. ['name', '=', '项目附件-财政局'],
  728. ['name', '=', '联系函-财政局'],
  729. ];
  730. $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
  731. $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
  732. $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
  733. $login_rules = explode(',', $login_rules);
  734. $rules_id = array();
  735. foreach ($list as $key => $value) {
  736. if ($value['name'] == "作业日志-财政局") {
  737. if (in_array($value['id'], $login_rules)) {
  738. $rules_id['project_comments'] = 1;
  739. } else {
  740. $rules_id['project_comments'] = 0;
  741. }
  742. } else if ($value['name'] == "工作记录-财政局") {
  743. if (in_array($value['id'], $login_rules)) {
  744. $rules_id['project_record'] = 1;
  745. } else {
  746. $rules_id['project_record'] = 0;
  747. }
  748. } else if ($value['name'] == "项目报告-财政局") {
  749. if (in_array($value['id'], $login_rules)) {
  750. $rules_id['project_report'] = 1;
  751. } else {
  752. $rules_id['project_report'] = 0;
  753. }
  754. } else if ($value['name'] == "项目人员-财政局") {
  755. if (in_array($value['id'], $login_rules)) {
  756. $rules_id['project_user'] = 1;
  757. } else {
  758. $rules_id['project_user'] = 0;
  759. }
  760. } else if ($value['name'] == "项目动态-财政局") {
  761. if (in_array($value['id'], $login_rules)) {
  762. $rules_id['project_log'] = 1;
  763. } else {
  764. $rules_id['project_log'] = 0;
  765. }
  766. } else if ($value['name'] == "项目附件-财政局") {
  767. if (in_array($value['id'], $login_rules)) {
  768. $rules_id['project_file'] = 1;
  769. } else {
  770. $rules_id['project_file'] = 0;
  771. }
  772. } else if ($value['name'] == "联系函-财政局") {
  773. if (in_array($value['id'], $login_rules)) {
  774. $rules_id['project_contact'] = 1;
  775. } else {
  776. $rules_id['project_contact'] = 0;
  777. }
  778. }
  779. }
  780. return $rules_id;
  781. }
  782. public function getProjectFiveCompany()
  783. {
  784. $where = [
  785. ['name', '=', '作业日志-公司'],
  786. ['name', '=', '工作记录-公司'],
  787. ['name', '=', '项目报告-公司'],
  788. ['name', '=', '项目人员-公司'],
  789. ['name', '=', '项目动态-公司'],
  790. ['name', '=', '项目附件-公司'],
  791. ['name', '=', '联系函-公司'],
  792. ];
  793. $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
  794. $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
  795. $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
  796. $login_rules = explode(',', $login_rules);
  797. $rules_id = array();
  798. foreach ($list as $key => $value) {
  799. if ($value['name'] == "作业日志-公司") {
  800. if (in_array($value['id'], $login_rules)) {
  801. $rules_id['project_comments'] = 1;
  802. } else {
  803. $rules_id['project_comments'] = 0;
  804. }
  805. } else if ($value['name'] == "工作记录-公司") {
  806. if (in_array($value['id'], $login_rules)) {
  807. $rules_id['project_record'] = 1;
  808. } else {
  809. $rules_id['project_record'] = 0;
  810. }
  811. } else if ($value['name'] == "项目报告-公司") {
  812. if (in_array($value['id'], $login_rules)) {
  813. $rules_id['project_report'] = 1;
  814. } else {
  815. $rules_id['project_report'] = 0;
  816. }
  817. } else if ($value['name'] == "项目人员-公司") {
  818. if (in_array($value['id'], $login_rules)) {
  819. $rules_id['project_user'] = 1;
  820. } else {
  821. $rules_id['project_user'] = 0;
  822. }
  823. } else if ($value['name'] == "项目动态-公司") {
  824. if (in_array($value['id'], $login_rules)) {
  825. $rules_id['project_log'] = 1;
  826. } else {
  827. $rules_id['project_log'] = 0;
  828. }
  829. } else if ($value['name'] == "项目附件-公司") {
  830. if (in_array($value['id'], $login_rules)) {
  831. $rules_id['project_file'] = 1;
  832. } else {
  833. $rules_id['project_file'] = 0;
  834. }
  835. } else if ($value['name'] == "联系函-公司") {
  836. if (in_array($value['id'], $login_rules)) {
  837. $rules_id['project_contact'] = 1;
  838. } else {
  839. $rules_id['project_contact'] = 0;
  840. }
  841. }
  842. }
  843. return $rules_id;
  844. }
  845. public function getProjectFiveYezhu()
  846. {
  847. $where = [
  848. ['name', '=', '作业日志-业主'],
  849. ['name', '=', '工作记录-业主'],
  850. ['name', '=', '项目报告-业主'],
  851. ['name', '=', '项目人员-业主'],
  852. ['name', '=', '项目动态-业主'],
  853. ['name', '=', '项目附件-业主'],
  854. ['name', '=', '联系函-业主'],
  855. ];
  856. $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
  857. $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
  858. $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
  859. $login_rules = explode(',', $login_rules);
  860. $rules_id = array();
  861. foreach ($list as $key => $value) {
  862. if ($value['name'] == "作业日志-业主") {
  863. if (in_array($value['id'], $login_rules)) {
  864. $rules_id['project_comments'] = 1;
  865. } else {
  866. $rules_id['project_comments'] = 0;
  867. }
  868. } else if ($value['name'] == "工作记录-业主") {
  869. if (in_array($value['id'], $login_rules)) {
  870. $rules_id['project_record'] = 1;
  871. } else {
  872. $rules_id['project_record'] = 0;
  873. }
  874. } else if ($value['name'] == "项目报告-业主") {
  875. if (in_array($value['id'], $login_rules)) {
  876. $rules_id['project_report'] = 1;
  877. } else {
  878. $rules_id['project_report'] = 0;
  879. }
  880. } else if ($value['name'] == "项目人员-业主") {
  881. if (in_array($value['id'], $login_rules)) {
  882. $rules_id['project_user'] = 1;
  883. } else {
  884. $rules_id['project_user'] = 0;
  885. }
  886. } else if ($value['name'] == "项目动态-业主") {
  887. if (in_array($value['id'], $login_rules)) {
  888. $rules_id['project_log'] = 1;
  889. } else {
  890. $rules_id['project_log'] = 0;
  891. }
  892. } else if ($value['name'] == "项目附件-业主") {
  893. if (in_array($value['id'], $login_rules)) {
  894. $rules_id['project_file'] = 1;
  895. } else {
  896. $rules_id['project_file'] = 0;
  897. }
  898. } else if ($value['name'] == "联系函-业主") {
  899. if (in_array($value['id'], $login_rules)) {
  900. $rules_id['project_contact'] = 1;
  901. } else {
  902. $rules_id['project_contact'] = 0;
  903. }
  904. }
  905. }
  906. return $rules_id;
  907. }
  908. public function read_company()
  909. {
  910. $param = get_params();
  911. $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
  912. // halt($param);
  913. $a = time();
  914. $id = isset($param["project_id"]) ? $param["project_id"] : $a;
  915. if ($id == $a) {
  916. $datas = array();
  917. $datas["data"] = null;
  918. return table_assign(0, "无项目", $datas);
  919. }
  920. $project = Db::name("appropriation_project")->where("uid", $id)->select();
  921. $datas["data"] = $project;
  922. $datas["total"] = count($project);
  923. if ($param["type"] > 9) {
  924. $a = time();
  925. $id = isset($param["project_id"]) ? $param["project_id"] : $a;
  926. $detail = Db::name("appropriation")->where("id", $id)->find();
  927. $file_array = Db::name('ProjectFile')
  928. ->field('mf.id,mf.topic_id,mf.admin_id,f.name,f.filesize,f.filepath,f.fileext,f.create_time,f.admin_id,a.nickname as admin_name')
  929. ->alias('mf')
  930. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  931. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  932. ->order('mf.create_time desc')
  933. ->where(array('mf.topic_id' => $id, 'mf.module' => 'appropriation'))
  934. ->select()->toArray();
  935. $where = [
  936. ["approver", "=", $this->uid],
  937. ["audit_status", "<", 5]
  938. ];
  939. $list = $this->Auditmodel->alias("a")->join("cost_project c", "a.project_id=c.id", "left")
  940. ->where($where)->where('audit_status',1)->where('audit_type','in',[10,11,12])
  941. ->field("a.*,c.project_num,c.project_status,c.engineering_type,c.sent_review_amount")
  942. ->paginate(9999, false, ['query' => $param])
  943. ->each(function ($item, $key) {
  944. $item->approver_name = Db::name("admin")->where("id", $item->approver)->value("nickname");
  945. })->toArray();
  946. // halt($list);
  947. $red = 0;
  948. foreach ($list["data"] as $item => $value) {
  949. if ($value["audit_status"] == 1) {
  950. $red = 1;
  951. }
  952. }
  953. $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
  954. $red_kan = 0;
  955. foreach ($red_id as $item => $value) {
  956. if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
  957. $red_kan = 1;
  958. }
  959. }
  960. if($unit_type == 2){
  961. $auditdata = $this->Auditmodel->where('id',$param['id'])->find();
  962. $detail['audit_status'] = $auditdata['audit_status'];
  963. View::assign('auditdata', $auditdata);
  964. }else{
  965. $detail['audit_status'] = 0;
  966. }
  967. // halt($audit_status,$id);
  968. // halt($list);
  969. View::assign('unit_type', $unit_type);
  970. View::assign('datas', $datas['data']);
  971. View::assign('id', $id);
  972. View::assign('detail', $detail);
  973. View::assign("red_kan", $red_kan);
  974. View::assign('red', $red);
  975. View::assign('file_array', $file_array);
  976. return view();
  977. }
  978. }
  979. public function datastat(){
  980. return View();
  981. }
  982. public function contract()
  983. {
  984. return view();
  985. }
  986. public function contract_detail()
  987. {
  988. return view();
  989. }
  990. public function kan_list()
  991. {
  992. //根据所登录的账号,查询跟本身有关的项目
  993. //2是公司,0是财政局,1是业主
  994. $param = get_params();
  995. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  996. $order = empty($param['order']) ? 'id desc' : $param['order'];
  997. if (isset($param["project_start_time"])) {
  998. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  999. }
  1000. if (isset($param["project_end_time"])) {
  1001. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  1002. }
  1003. $where3 = [];//搜索条件
  1004. if (!empty($param['project_status'])) {
  1005. $where3[] = ['project_status', '=', $param['project_status']];
  1006. }
  1007. if (!empty($param['province'])) {
  1008. $where3[] = ['province', '=', $param['province']];
  1009. }
  1010. if (!empty($param['city'])) {
  1011. $where3[] = ['city', '=', $param['city']];
  1012. }
  1013. if (!empty($param['area'])) {
  1014. $where3[] = ['area', '=', $param['area']];
  1015. }
  1016. if (!empty($param['project_end_time'])) {
  1017. $where3[] = ['project_end_time', '<', $param['project_end_time']];
  1018. }
  1019. if (!empty($param['project_start_time'])) {
  1020. $where3[] = ['project_start_time', '>', $param['project_start_time']];
  1021. }
  1022. if (!empty($param['keyword'])) {
  1023. $keyword = $param['keyword'];
  1024. $where3[] = ['project_num|project_name|review_unit', 'like', '%' . $keyword . '%'];
  1025. }
  1026. if (!empty($param['review_unit_name'])) {
  1027. $where3[] = ['review_unit_name', 'like', '%' . $param['review_unit_name'] . '%'];
  1028. }
  1029. if (!empty($param['sent_review_unit_name'])) {
  1030. $where3[] = ['sent_review_unit_name', 'like', '%' . $param['sent_review_unit_name'] . '%'];
  1031. }
  1032. if (!empty($param['entrust_unit_name'])) {
  1033. $where3[] = ['entrust_unit_name', 'like', '%' . $param['entrust_unit_name'] . '%'];
  1034. }
  1035. $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
  1036. $inarr = array();
  1037. if ($unit_type == 0) {
  1038. $where[] = ["delete_time", "=", 0];
  1039. $where[] = ["project_status", ">", 0];
  1040. $where[] = ["entrust_unit", "=", get_login_admin('unit_name')];
  1041. $where2[] = ["delete_time", "=", 0];
  1042. $where2[] = ["project_status", ">", 0];
  1043. $where2[] = ["entrust_unit", "=", get_login_admin('unit_name')];
  1044. //项目可见的权限
  1045. $field = $this->Field->get_field_rules_new($this->uid);
  1046. //1全部-可查看可编辑,2全部-可查看,0与我有关
  1047. $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
  1048. if ($see_auth == 3) {
  1049. $where[] = ["entrust_maker", "=", $this->uid];
  1050. $where2[] = ["entrust_approver", "=", $this->uid];
  1051. $where2[] = ["project_status", ">", 1];
  1052. } elseif ($see_auth == 0) {
  1053. $where[] = ["entrust_maker", "=", $this->uid];
  1054. $where[] = ["project_status", ">", 0];
  1055. $where2[] = ["entrust_approver", "=", $this->uid];
  1056. $where2[] = ["project_status", ">", 1];
  1057. }
  1058. $list = $this->model->where($where3)
  1059. ->where(function ($query) use ($where,$where2) {
  1060. // 第一组条件(entrust_maker)
  1061. $query->where(function ($q1) use ($where) {
  1062. $q1->where($where);
  1063. });
  1064. // 使用 OR 连接第二组条件(entrust_approver)
  1065. $query->whereOr(function ($q2) use ($where2) {
  1066. $q2->where($where2);
  1067. });
  1068. })
  1069. ->order("create_time desc")->paginate(9999, false, ['query' => $param])
  1070. ->each(function ($item) {
  1071. $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
  1072. if ($red) {
  1073. if ($red["detail"] || $red["comment"] || $red["report"] || $red["user"] || $red["contact"]) {
  1074. $item->red = 1;
  1075. } else {
  1076. $item->red = 0;
  1077. }
  1078. } else {
  1079. $item->red = 0;
  1080. }
  1081. if (($item->province && $item->city && $item->area)) {
  1082. $item->project_region = $item->province . '-' . $item->city . '-' . $item->area;
  1083. }
  1084. })->toArray();
  1085. } elseif ($unit_type == 2) {
  1086. $order = empty($param['order']) ? 'project_receive_time desc,id desc' : $param['order'];
  1087. $where = [
  1088. ["delete_time", "=", 0],
  1089. ["project_status", ">", 3],
  1090. ["review_unit", "=", get_login_admin("unit_name")]
  1091. ];
  1092. $review_unit = $this->model->where($where)->where($where3)->field('id,review_head,operate_head,operate_team')->select()->toArray();
  1093. for ($i = 0; $i < count($review_unit); $i++) {
  1094. $a = $review_unit[$i];
  1095. $ids = $a["review_head"] . ',' . $a["operate_head"] . ',' . $a["operate_team"];
  1096. $ids = explode(",", $ids);
  1097. $c = in_array($this->uid, $ids);
  1098. if ($c) {
  1099. $inarr[] = $a["id"];
  1100. }
  1101. }
  1102. $field = $this->Field->get_field_rules_New($this->uid);
  1103. $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
  1104. $this->see_auth = $see_auth;
  1105. if ($see_auth == 3) {
  1106. $list = $this->model
  1107. ->where($where)->where($where3)->whereIn("id", $inarr)
  1108. ->order($order)->paginate(9999, false, ['query' => $param])
  1109. ->each(function ($item) {
  1110. $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
  1111. if ($red) {
  1112. if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
  1113. $item->red = 1;
  1114. } else {
  1115. $item->red = 0;
  1116. }
  1117. } else {
  1118. $item->red = 0;
  1119. }
  1120. })->toArray();
  1121. } elseif ($see_auth == 0) {
  1122. $list = $this->model
  1123. ->where($where)->where($where3)->whereIn("id", $inarr)
  1124. ->order($order)->paginate(9999, false, ['query' => $param])
  1125. ->each(function ($item) {
  1126. $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
  1127. if ($red) {
  1128. if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
  1129. $item->red = 1;
  1130. } else {
  1131. $item->red = 0;
  1132. }
  1133. } else {
  1134. $item->red = 0;
  1135. }
  1136. })->toArray();
  1137. } else {
  1138. $list = $this->model
  1139. ->where($where)
  1140. ->order($order)->where($where3)->paginate(9999, false, ['query' => $param])
  1141. ->each(function ($item) {
  1142. $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
  1143. if ($red) {
  1144. if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
  1145. $item->red = 1;
  1146. } else {
  1147. $item->red = 0;
  1148. }
  1149. } else {
  1150. $item->red = 0;
  1151. }
  1152. })->toArray();
  1153. }
  1154. } elseif ($unit_type == 1) {
  1155. $field = $this->Field->get_field_rules_New($this->uid);
  1156. $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
  1157. if ($see_auth == 0 || $see_auth == 3) {
  1158. $where = [
  1159. ["delete_time", "=", 0],
  1160. ["sent_review_unit", "=", get_login_admin("unit_name")],
  1161. ["sent_review_head", "=", $this->uid]
  1162. ];
  1163. } else {
  1164. $where = [
  1165. ["delete_time", "=", 0],
  1166. ["sent_review_unit", "=", get_login_admin("unit_name")]
  1167. ];
  1168. }
  1169. $list = $this->model
  1170. ->where($where)
  1171. ->order($order)->where($where3)->paginate(9999, false, ['query' => $param])
  1172. ->each(function ($item) {
  1173. $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
  1174. if ($red) {
  1175. if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
  1176. $item->red = 1;
  1177. } else {
  1178. $item->red = 0;
  1179. }
  1180. } else {
  1181. $item->red = 0;
  1182. }
  1183. })->toArray();
  1184. } else {
  1185. $list["data"] = [];
  1186. }
  1187. $data = $list["data"];
  1188. $real_list = array_values(array_column($data, NULL, 'id'));
  1189. $red = $this->Auditmodel->where("approver", $this->uid)->where("audit_status", 1)->count();
  1190. $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
  1191. $red_kan = 0;
  1192. foreach ($red_id as $item => $value) {
  1193. if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
  1194. $red_kan = 1;
  1195. }
  1196. }
  1197. View::assign("red_kan", $red_kan);
  1198. View::assign("detail", $real_list);
  1199. View::assign("red", $red);
  1200. View::assign("unit_type", $unit_type);
  1201. return view();
  1202. }
  1203. }