Temporary.php 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123
  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. }