Temporary.php 44 KB

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