Temporary.php 52 KB

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