Cost.php 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. <?php
  2. //declare (strict_types=1);
  3. namespace app\admin\controller\project;
  4. use app\admin\BaseController;
  5. use app\admin\model\Admin;
  6. use app\admin\model\Department as DepartmentModel;
  7. use app\admin\model\CostProject as CostProjectModel;
  8. use app\admin\model\ProjectAudit;
  9. use app\admin\model\ProjectMsg;
  10. use app\admin\model\ProjectFile;
  11. use app\admin\validate\project\CostProjectValidate;
  12. use app\wechat\controller\Officialaccount;
  13. use think\exception\ValidateException;
  14. use think\facade\Db;
  15. use think\facade\View;
  16. use think\App;
  17. use app\admin\controller\field\Field;
  18. use app\admin\controller\Pushmessage;
  19. class Cost extends BaseController
  20. {
  21. private array $field_name = [
  22. 'project_num' => '项目编号',
  23. "project_name" => "项目名称",
  24. "project_start_time" => "项目开始时间",
  25. "project_end_time" => "项目结束时间",
  26. "review_unit" => "评审单位",
  27. "sent_review_unit" => "送审单位",
  28. "sent_review_head" => "送审单位负责人",
  29. "sent_review_phone" => "送审单位负责人电话",
  30. "construction_unit" => "施工单位",
  31. "construction_head" => "施工单位负责人",
  32. "construction_phone" => "施工单位负责人电话",
  33. "sent_review_amount" => "送审金额",
  34. "engineering_type" => '工程类型',
  35. ];
  36. /**
  37. * 构造函数
  38. */
  39. public function __construct(App $app)
  40. {
  41. parent::__construct($app);
  42. $this->Field = new Field($this->app);
  43. $this->department = new DepartmentModel();
  44. $this->model = new CostProjectModel();
  45. $this->ProjectMsg = new ProjectMsg();
  46. $this->filemodel = new ProjectFile();
  47. $this->uid = get_login_admin('id');
  48. $this->Adminmodel = new Admin();
  49. $this->time = time();
  50. $this->Officialaccount = new Officialaccount();
  51. $this->Pushmessage = new Pushmessage();
  52. }
  53. /**
  54. * 数据列表
  55. */
  56. public function datalist()
  57. {
  58. if (request()->isAjax()) {
  59. $param = get_params();
  60. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  61. $order = empty($param['order']) ? 'id desc' : $param['order'];
  62. if (isset($param["project_start_time"])) {
  63. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  64. }
  65. if (isset($param["project_end_time"])) {
  66. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  67. }
  68. //项目可见的权限
  69. $field = $this->Field->get_field_rules_new($this->uid);
  70. //1全部-可查看可编辑,2全部-可查看,0与我有关
  71. $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
  72. $where[] = ["delete_time", "=", 0];
  73. $where[] = ["project_status", ">", 0];
  74. $where2[] = ["delete_time", "=", 0];
  75. $where2[] = ["project_status", ">", 0];
  76. if ($see_auth == 3||$see_auth == 0) {
  77. $where[] = ["entrust_maker", "=", $this->uid];
  78. $where2[] = ["entrust_approver", "=", $this->uid];
  79. $where2[] = ["project_status", ">", 1];
  80. }
  81. $where3 =[];
  82. if (!empty($param['project_status'])) {
  83. $where3[] = ['project_status', '=', $param['project_status']];
  84. }
  85. if (!empty($param['province'])) {
  86. $where3[] = ['province', '=', $param['province']];
  87. }
  88. if (!empty($param['city'])) {
  89. $where3[] = ['city', '=', $param['city']];
  90. }
  91. if (!empty($param['area'])) {
  92. $where3[] = ['area', '=', $param['area']];
  93. }
  94. if (!empty($param['project_end_time'])) {
  95. $where3[] = ['project_end_time', '<', $param['project_end_time']];
  96. }
  97. if (!empty($param['project_start_time'])) {
  98. $where3[] = ['project_start_time', '>', $param['project_start_time']];
  99. }
  100. if (!empty($param['keyword'])) {
  101. $keyword = $param['keyword'];
  102. $where3[] = ['project_num|project_name|review_unit', 'like', '%' . $keyword . '%'];
  103. }
  104. if (!empty($param['review_head_name'])) {
  105. $where3[] = ['review_head_name', 'like', '%' . $param['review_head_name'] . '%'];
  106. }
  107. if (!empty($param['review_unit_name'])) {
  108. $where3[] = ['review_unit_name', 'like', '%' . $param['review_unit_name']. '%'];
  109. }
  110. if (!empty($param['sent_review_unit_name'])) {
  111. $where3[] = ['sent_review_unit_name', 'like', '%' . $param['sent_review_unit_name']. '%'];
  112. }
  113. $where3[] = ["entrust_unit", "=", get_login_admin('unit_name')];
  114. $this->see_auth = $see_auth;
  115. $list = $this->model
  116. ->where($where3)->where(function ($query) use ($where,$where2) {
  117. // 第一组条件(entrust_maker)
  118. $query->where(function ($q1) use ($where) {
  119. $q1->where($where);
  120. });
  121. // 使用 OR 连接第二组条件(entrust_approver)
  122. $query->whereOr(function ($q2) use ($where2) {
  123. $q2->where($where2);
  124. });
  125. })
  126. ->order($order)->paginate($rows, false, ['query' => $param])
  127. ->each(function ($item) {
  128. $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
  129. if ($red) {
  130. if ($red["detail"] || $red["comment"] || $red["report"] || $red["user"] || $red["contact"]) {
  131. $item->red = 1;
  132. }
  133. } else {
  134. $item->red = 0;
  135. }
  136. if (($item->province && $item->city && $item->area)) {
  137. $item->project_region = $item->province . '-' . $item->city . '-' . $item->area;
  138. }
  139. $item->creator = Db::name("admin")->where("id",$item->creator)->value("nickname");
  140. $item->self_id = $this->see_auth;
  141. //作业人
  142. $operate_team_names = null;
  143. $operate_team_names_ids = explode(",", $item->operate_team);
  144. for ($i = 0; $i < count($operate_team_names_ids); $i++) {
  145. $name = Db::name("admin")->where("id", $operate_team_names_ids[$i])->value("nickname");
  146. if (!($i == 0)) {
  147. $name = "," . $name;
  148. }
  149. $operate_team_names = $operate_team_names . $name;
  150. }
  151. $item->operate_team_names = $operate_team_names;
  152. });
  153. return table_assign(0, '', $list);
  154. } else {
  155. $field = $this->Field->get_field_rules_new($this->uid);
  156. $fields = [];
  157. foreach ($field as $k=>$v){
  158. if($v!=1){
  159. $fields[$k] = true;
  160. }else{
  161. $fields[$k] = false;
  162. }
  163. }
  164. View::assign('field', $fields);
  165. return view();
  166. }
  167. }
  168. /**
  169. * 临期
  170. */
  171. public function list()
  172. {
  173. // if (request()->isAjax()) {
  174. $param = get_params();
  175. $field = $this->Field->get_field_rules_new($this->uid);
  176. $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
  177. $where = array();
  178. $where3 = array();
  179. if ($see_auth == 3 || $see_auth == 0) {
  180. $where = [
  181. ["entrust_maker", "=", $this->uid],
  182. ];
  183. $where3 = [
  184. ["entrust_approver", "=", $this->uid],
  185. ["project_status", ">", 1]
  186. ];
  187. }
  188. $where1 = [
  189. ["delete_time", "=", 0],
  190. ['project_end_time', '<', strtotime('15 days')],
  191. ['project_end_time', '>', time()],
  192. ["project_status", "<", 7],
  193. ["entrust_unit","=",get_login_admin("unit_name")]
  194. ];
  195. $where1 = array_merge($where, $where1);
  196. $where2 = array_merge($where1, $where3);
  197. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  198. $order = empty($param['order']) ? 'id desc' : $param['order'];
  199. $list = $this->model->whereOr([$where1, $where2])
  200. ->order($order)
  201. ->paginate(9999, false, ['query' => $param])
  202. ->each(function ($item) {
  203. });
  204. return table_assign(0, '', $list);
  205. // }
  206. }
  207. /**
  208. * 逾期
  209. */
  210. public function list2()
  211. {
  212. $param = get_params();
  213. $field = $this->Field->get_field_rules_new($this->uid);
  214. $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
  215. $where = array();
  216. $where3 = array();
  217. if ($see_auth == 3 || $see_auth == 0) {
  218. $where = [
  219. ["entrust_maker", "=", $this->uid],
  220. ];
  221. $where3 = [
  222. ["entrust_approver", "=", $this->uid],
  223. ["project_status", ">", 1]
  224. ];
  225. }
  226. $where2 = [
  227. ["delete_time", "=", 0],
  228. ['project_end_time', '<', time()],
  229. ["project_status", "<", 7],
  230. ["entrust_unit","=",get_login_admin("unit_name")]
  231. ];
  232. $where1 = array_merge($where, $where2);
  233. $where2 = array_merge($where2, $where3);
  234. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  235. $order = empty($param['order']) ? 'id desc' : $param['order'];
  236. $list = $this->model->whereOr([$where1, $where2])
  237. ->order($order)->paginate(9999, false, ['query' => $param]);
  238. return table_assign(0, '', $list);
  239. // }
  240. }
  241. /**
  242. * 添加
  243. */
  244. public function add()
  245. {
  246. if (request()->isAjax()) {
  247. $param = get_params();
  248. // halt($param);
  249. // 检验完整性
  250. try {
  251. validate(CostProjectValidate::class)->check($param);
  252. } catch (ValidateException $e) {
  253. // 验证失败 输出错误信息
  254. return to_assign(1, $e->getError());
  255. }
  256. if (isset($param["project_start_time"])) {
  257. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  258. }
  259. if (isset($param["project_end_time"])) {
  260. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  261. }
  262. $param["entrust_unit"] = get_login_admin("unit_name");
  263. $param["entrust_unit_name"] = Db::name("department")->where("id", get_login_admin("unit_name"))->value("title");
  264. $param["entrust_maker"] = $this->uid;
  265. $param["entrust_maker_name"] = get_login_admin("nickname");
  266. $param["entrust_phone"] = get_login_admin("mobile");
  267. $param["entrust_approver_name"] = get_admin($param["entrust_approver"])["nickname"];
  268. $param["project_status"] = 1;
  269. $param["maker_type"] = 1;
  270. $param["creator"] = $this->uid;
  271. $file_ids = isset($param["file_ids"]) ? $param["file_ids"] : 0;
  272. unset($param["file_ids"]);
  273. $file_id = [];
  274. $insertId = 0;
  275. try {
  276. $param['create_time'] = time();
  277. $insertId = $this->model->strict(false)->field(true)->insertGetId($param);
  278. if ($file_ids) {
  279. for ($a = 0; $a < count($file_ids); $a++) {
  280. $file_id[] = ["id" => $file_ids[$a], "topic_id" => $insertId];
  281. }
  282. $this->filemodel->saveAll($file_id);
  283. }
  284. add_log('add', $insertId, $param);
  285. add_project_log("创建项目", $insertId, "创建项目");
  286. add_user($param["entrust_maker"], $insertId);
  287. add_user($param["entrust_approver"], $insertId);
  288. } catch (\Exception $e) {
  289. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  290. }
  291. return to_assign(0, '操作成功', ['aid' => $insertId]);
  292. //有日志了
  293. } else {
  294. //拿到自身的所属于单位和职位,查询和自身单位一样的账号,
  295. //
  296. $unit_name = Db::name('admin')->where('id', $this->uid)->value('unit_name');
  297. $person = Db::name("admin")->where("unit_name", $unit_name)->where("status",">",0)->field(["id", "nickname"])->select()->toArray();
  298. // for ($a = 0; $a < count($person); $a++) {
  299. // if ($person[$a]["id"] == $this->uid) {
  300. // unset($person[$a]);
  301. // }
  302. // }
  303. $person = array_values($person);
  304. View::assign("person", $person);
  305. return view();
  306. }
  307. }
  308. public function getemployeelist()
  309. {
  310. if (request()->isAjax()) {
  311. $data = $this->request->param();
  312. $person = Db::name("admin")->where([["unit_name", "=", $data['id']], ["status", "=", 1]])->field(["id", "nickname", "mobile"])->select();
  313. return $person;
  314. }
  315. }
  316. /**
  317. * 提交审批
  318. */
  319. public function save()
  320. {
  321. if (request()->isAjax()) {
  322. $param = get_params();
  323. $handle = $this->Pushmessage->handleParam($param);
  324. $param = $handle['param'];
  325. // halt($param);
  326. // 检验完整性
  327. try {
  328. validate(CostProjectValidate::class)->check($param);
  329. } catch (ValidateException $e) {
  330. // 验证失败 输出错误信息
  331. return to_assign(1, $e->getError());
  332. }
  333. if (isset($param["project_start_time"])) {
  334. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  335. }
  336. if (isset($param["project_end_time"])) {
  337. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  338. }
  339. $param["entrust_unit"] = get_login_admin("unit_name");
  340. $param["entrust_unit_name"] = Db::name("department")->where("id", get_login_admin("unit_name"))->value("title");
  341. $param["entrust_maker"] = $this->uid;
  342. $param["entrust_maker_name"] = get_login_admin("nickname");
  343. $param["entrust_phone"] = get_login_admin("mobile");
  344. $param["entrust_approver_name"] = get_admin($param["entrust_approver"])["nickname"];
  345. //提交后状态改变为2,待审批中
  346. $param["project_status"] = 2;
  347. $param["maker_type"] = 1;
  348. if ($param["id"] == 0) {
  349. $file_id = [];
  350. $file_ids = isset($param["file_ids"]) ? $param["file_ids"] : 0;
  351. unset($param["file_ids"]);
  352. // try {
  353. $param['create_time'] = time();
  354. $param['update_time'] = time();
  355. $param["creator"] = $this->uid;
  356. $insertGetId = $this->model->where('id', $param['id'])->strict(false)->field(true)->insertGetId($param);
  357. if ($file_ids) {
  358. for ($a = 0; $a < count($file_ids); $a++) {
  359. $file_id[] = ["id" => $file_ids[$a], "topic_id" => $insertGetId];
  360. }
  361. $this->filemodel->saveAll($file_id);
  362. }
  363. //审批记录,project_status=2,审批中
  364. $auditData = [
  365. "project_id" => $insertGetId,
  366. "project_name" => $param["project_name"],
  367. "project_type" => "造价项目",
  368. "audit_name" => "项目分配审核",
  369. "audit_type" => 1,
  370. "sponsor" => Db::name('admin')->where("id", $this->uid)->value("nickname"),
  371. "sponsor_id" => $this->uid,
  372. "sponsor_unit" => $param["review_unit_name"],
  373. "approver" => $param["entrust_approver"],
  374. "approver_name" => Db::name('admin')->where("id", $param["entrust_approver"])->value("nickname"),
  375. "create_time" => time()
  376. ];
  377. ProjectAudit::create($auditData);
  378. //审批记录end
  379. $MsgData = [
  380. "uid" => $auditData["approver"],
  381. "project_id" => $insertGetId,
  382. "content" => get_login_admin("nickname") . "向您发起了一个" . $auditData["audit_name"],
  383. "create_time" => time()
  384. ];
  385. $MsgGetId = $this->ProjectMsg->insertGetId($MsgData);
  386. $unread = Db::name("admin")->where("id", $auditData["approver"])->value("unread");
  387. if (!empty($unread)) {
  388. $unread = $unread . "," . $MsgGetId;
  389. } else {
  390. $unread = $MsgGetId;
  391. }
  392. Db::name("admin")->where("id", $auditData["approver"])->update(["unread" => $unread]);
  393. add_log('edit', $insertGetId, $param);
  394. add_project_log("创建项目", $insertGetId, "创建项目");
  395. add_project_log("提交立项审批", $insertGetId, "提交立项审批");
  396. add_user($param["entrust_maker"], $insertGetId);
  397. add_user($param["entrust_approver"], $insertGetId);
  398. // $handle['financial'] = array_unique(array_merge((array) $param['entrust_approver'], $handle['financial']));
  399. // $handle['company'] = array_unique(array_merge((array) $param['entrust_approver'], $handle['company']));
  400. if(empty($handle['financial'])){
  401. $handle['financial'] = (array)$param['entrust_approver'];
  402. }else{
  403. $handle['financial'] = array_merge($handle['financial'], $param['entrust_approver']);
  404. }
  405. // halt($handle['financial'], $handle['company']);
  406. $this->Pushmessage->pushMessage($insertGetId, $handle['financial'], $handle['company']);
  407. // } catch (\Exception $e) {
  408. // return to_assign(1, '操作失败,原因:' . $e->getMessage());
  409. // }
  410. } else {
  411. //编辑
  412. try {
  413. $file_ids = isset($param["file_ids"]) ? $param["file_ids"] : 0;
  414. unset($param["file_ids"]);
  415. $param['update_time'] = time();
  416. $this->model->where('id', $param['id'])->strict(false)->field(true)->update($param);
  417. if ($file_ids) {
  418. for ($a = 0; $a < count($file_ids); $a++) {
  419. $file_id[] = ["id" => $file_ids[$a], "topic_id" => $param['id']];
  420. }
  421. $this->filemodel->saveAll($file_id);
  422. }
  423. //审批记录,project_status=2,审批中
  424. $auditData = [
  425. "project_id" => $param['id'],
  426. "project_name" => $param["project_name"],
  427. "project_type" => "造价项目",
  428. "audit_name" => "项目分配审核",
  429. "audit_type" => 1,
  430. "sponsor" => Db::name('admin')->where("id", $this->uid)->value("nickname"),
  431. "sponsor_id" => $this->uid,
  432. "sponsor_unit" => $param["review_unit_name"],
  433. "approver" => $param["entrust_approver"],
  434. "approver_name" => Db::name('admin')->where("id", $param["entrust_approver"])->value("nickname"),
  435. "create_time" => time()
  436. ];
  437. ProjectAudit::create($auditData);
  438. //审批记录end
  439. $MsgData = [
  440. "uid" => $auditData["approver"],
  441. "project_id" => $param['id'],
  442. "content" => get_login_admin("nickname") . "向您发起了一个" . $auditData["audit_name"],
  443. "create_time" => time()
  444. ];
  445. $MsgGetId = $this->ProjectMsg->insertGetId($MsgData);
  446. $unread = Db::name("admin")->where("id", $auditData["approver"])->value("unread");
  447. if (!empty($unread)) {
  448. $unread = $unread . "," . $MsgGetId;
  449. } else {
  450. $unread = $MsgGetId;
  451. }
  452. Db::name("admin")->where("id", $auditData["approver"])->update(["unread" => $unread]);
  453. add_project_log("提交立项审批", $param['id'], "提交立项审批");
  454. add_user($param["entrust_approver"], $param['id']);
  455. // $handle['financial'] = array_unique(array_merge((array) $param['entrust_approver'], $handle['financial']));
  456. // $handle['company'] = array_unique(array_merge((array) $param['entrust_approver'], $handle['company']));
  457. if(empty($handle['financial'])){
  458. $handle['financial'] = (array)$param['entrust_approver'];
  459. }else{
  460. $handle['financial'] = array_merge($handle['financial'], $param['entrust_approver']);
  461. }
  462. $this->Pushmessage->pushMessage($param['id'], $handle['financial'], $handle['company']);
  463. } catch (\Exception $e) {
  464. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  465. }
  466. }
  467. return to_assign(0, "操作成功");
  468. }
  469. }
  470. /**
  471. * 撤回
  472. */
  473. public function withdraw()
  474. {
  475. if (request()->isAjax()) {
  476. $param = get_params();
  477. $status = Db::name("cost_project")->where("id", $param["id"])->field("project_status")->select();
  478. // halt($status[0]["status"]);
  479. if ($status[0]["project_status"] < 3) {
  480. if (isset($param["project_start_time"])) {
  481. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  482. }
  483. if (isset($param["project_end_time"])) {
  484. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  485. }
  486. $param = array_merge($param, ["project_status" => 1]);
  487. try {
  488. $param['update_time'] = time();
  489. $this->model->where('id', $param['id'])->strict(false)->field(true)->update($param);
  490. ProjectAudit::where([["project_id", "=", $param["id"]], ["audit_status", "=", 1], ["audit_name","=","项目分配审核"]])->delete();
  491. add_log('edit', $param['id'], $param);
  492. add_project_log('撤回', $param['id'], "撤回");
  493. } catch (\Exception $e) {
  494. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  495. }
  496. return to_assign(0, "操作成功");
  497. } else {
  498. return to_assign(0, "已审核,无法撤回");
  499. }
  500. }
  501. }
  502. /**
  503. * 编辑|保存
  504. */
  505. public function edit()
  506. {
  507. $param = get_params();
  508. // halt($param);
  509. $type = isset($param['type']) ? $param['type'] : 0;
  510. if (request()->isAjax()) {
  511. // halt($param);
  512. if ($type == 2) {
  513. $id = isset($param['id']) ? $param['id'] : 0;
  514. $detail = $this->model->getCostProjectById($id);
  515. $review_unit_name = Db::name('department')->where(['id' => $detail["review_unit"]])->value('title');
  516. $unit_name = Db::name('admin')->where('id', $this->uid)->value('unit_name');
  517. $person = Db::name("admin")->where([["unit_name", "=", $unit_name], ["status", "=", 1]])->field(["id", "nickname"])->select()->toArray();
  518. // for ($a = 0; $a < count($person); $a++) {
  519. // if ($person[$a]["id"] == $this->uid) {
  520. // unset($person[$a]);
  521. // }
  522. // }
  523. // $person = array_values($person);
  524. $review_person = Db::name("admin")->where([["unit_name", "=", $detail["review_unit"]], ["status", "=", 1]])->field(["id", "nickname"])->select();
  525. $review_name = Db::name("admin")->where("id", $detail['review_head'])->field(["id", "nickname"])->find();
  526. $audit = Db::name("project_audit")->where([["project_id", "=", $id], ["sponsor_id", "=", $this->uid]])->order('create_time', 'desc')->select();
  527. $file_array = Db::name('ProjectFile')
  528. ->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')
  529. ->alias('mf')
  530. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  531. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  532. ->order('mf.create_time desc')
  533. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  534. ->select()->toArray();
  535. $comment_type = isset($param["comment_type"])?$param['comment_type'] : 0;
  536. $comment = Db::name("project_comment")->where("type",$comment_type)
  537. ->where("project_id", $id)->order('create_time', 'asc')->select();
  538. $project_log = self::project_log($id);
  539. View::assign('project_log', $project_log);
  540. $field = $this->Field->get_field_rules_new($this->uid);
  541. $field_edit = $this->Field->get_field_rules_edit_new($this->uid);
  542. $c = $detail['project_end_time'] - time();
  543. if ($c > 0) {
  544. $advent_time = floor($c / 86400) . "天";
  545. } else {
  546. $c = -$c;
  547. $advent_time = floor($c / 86400) . "天";
  548. }
  549. if (!empty($detail)) {
  550. View::assign('advent_time', $advent_time);
  551. View::assign('comment', $comment);
  552. View::assign('project_id', $id);
  553. View::assign("audit", $audit);
  554. View::assign("review_name", $review_name);
  555. View::assign("review_person", $review_person);
  556. View::assign("person", $person);
  557. View::assign('detail', $detail);
  558. View::assign('review_unit_name', $review_unit_name);
  559. View::assign('field', $field);
  560. // dump($field_edit);
  561. View::assign('field_edit', $field_edit);
  562. View::assign('file_array', $file_array);
  563. View::assign('project_five', self::getProjectFive());
  564. return view();
  565. } else {
  566. throw new \think\exception\HttpException(404, '找不到页面');
  567. }
  568. }
  569. if (isset($param["project_start_time"])) {
  570. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  571. }
  572. if (isset($param["project_end_time"])) {
  573. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  574. }
  575. $field_name = array_keys($this->field_name);
  576. $ab = $this->model->where("id", $param["id"])->field($field_name)->find()->toArray();
  577. $ab["project_start_time"] = date('Y-m-d', $ab["project_start_time"]);
  578. $ab["project_end_time"] = date('Y-m-d', $ab["project_end_time"]);
  579. $c = array_intersect_key($param, $ab);
  580. if (isset($c["project_start_time"])) {
  581. $c["project_start_time"] = date('Y-m-d', $c["project_start_time"]);
  582. }
  583. if (isset($c["project_end_time"])) {
  584. $c["project_end_time"] = date('Y-m-d', $c["project_end_time"]);
  585. }
  586. $maker_name = get_login_admin("nickname");
  587. $content = '';
  588. foreach ($c as $key => $value) {
  589. if ($c[$key] !== $ab[$key]) {
  590. $value = !empty($value) ? $value : "无";
  591. $content = $content . $this->field_name[$key] . "从" . $ab[$key] . "修改为" . $value . ",";
  592. }
  593. }
  594. $content = rtrim($content, ",");
  595. if (empty($content)) {
  596. $content = "无修改";
  597. }
  598. add_project_log('编辑', $param["id"], $content, 1);
  599. $this->model->editCostProject($param);
  600. } else {
  601. $id = isset($param['id']) ? $param['id'] : 0;
  602. $detail = $this->model->getCostProjectById($id);
  603. $review_unit_name = Db::name('department')->where(['id' => $detail["review_unit"]])->value('title');
  604. $unit_name = get_login_admin("unit_name");
  605. $person = Db::name("admin")->where([["unit_name", "=", $unit_name], ["status", "=", 1]])->field(["id", "nickname"])->select()->toArray();
  606. // for ($a = 0; $a < count($person); $a++) {
  607. // if ($person[$a]["id"] == $this->uid) {
  608. // unset($person[$a]);
  609. // }
  610. // }
  611. // $person = array_values($person);
  612. $review_person = Db::name("admin")->where([["unit_name", "=", $detail["review_unit"]], ["status", "=", 1]])->field(["id", "nickname"])->select();
  613. $review_name = Db::name("admin")->where("id", $detail['review_head'])->field(["id", "nickname"])->find();
  614. $audit = Db::name("project_audit")->where([["project_id", "=", $id], ["sponsor_id", "=", $this->uid]])->order('create_time', 'desc')->select();
  615. $file_array = Db::name('ProjectFile')
  616. ->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')
  617. ->alias('mf')
  618. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  619. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  620. ->order('mf.create_time desc')
  621. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  622. ->select()->toArray();
  623. $comment_type = isset($param["comment_type"])?$param['comment_type'] : 0;
  624. $comment = Db::name("project_comment")->where("type",$comment_type)
  625. ->where("project_id", $id)->order('create_time', 'asc')->select();
  626. $project_log = self::project_log($id);
  627. View::assign('project_log', $project_log);
  628. $field = $this->Field->get_field_rules_new($this->uid);
  629. $field_edit = $this->Field->get_field_rules_edit_new($this->uid);
  630. //小红点消息
  631. $red = Db::name("new_msg")->where([["uid", '=', $this->uid], ["project_id", "=", $id]])->field('detail,comment,report,user,contact')->find();
  632. if (empty($red)) {
  633. $red = ["detail" => 0, "comment" => 0, "report" => 0, "user" => 0, "contact" => 0];
  634. }
  635. // dump($red);
  636. $c = $detail['project_end_time'] - time();
  637. if ($c > 0) {
  638. $advent_time = floor($c / 86400) . "天";
  639. } else {
  640. $c = -$c;
  641. $advent_time = floor($c / 86400) . "天";
  642. }
  643. if (!empty($detail)) {
  644. View::assign('advent_time', $advent_time);
  645. View::assign('comment', $comment);
  646. View::assign('project_id', $id);
  647. View::assign('red', $red);
  648. View::assign("audit", $audit);
  649. View::assign("review_name", $review_name);
  650. View::assign("review_person", $review_person);
  651. View::assign("person", $person);
  652. View::assign('detail', $detail);
  653. View::assign('review_unit_name', $review_unit_name);
  654. View::assign('field', $field);
  655. // dump($field_edit);
  656. View::assign('field_edit', $field_edit);
  657. View::assign('file_array', $file_array);
  658. View::assign('project_five', self::getProjectFive());
  659. return view();
  660. } else {
  661. throw new \think\exception\HttpException(404, '找不到页面');
  662. }
  663. }
  664. }
  665. public function get_file(){
  666. $param = get_params();
  667. $id = isset($param['id']) ? $param['id'] : 0;
  668. $file_array = Db::name('ProjectFile')
  669. ->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,mf.remark')
  670. ->alias('mf')
  671. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  672. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  673. ->order('mf.create_time desc')
  674. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  675. ->paginate(9999, false, ['query' => $param]);
  676. return table_assign(0, '', $file_array);
  677. }
  678. public function project_log($project_id)
  679. {
  680. // $project_id = 24;
  681. $login_admin = get_admin(get_login_admin('id'));
  682. $where = array();
  683. if ($login_admin['user_type'] == 2) {
  684. $where = [
  685. ['project_status', '>=', 3],
  686. ['unit_name', '=', $login_admin['unit_name']],
  687. ];
  688. } else {
  689. if ($login_admin['permission'] != 1) {
  690. $where = [
  691. ['unit_name', '=', $login_admin['unit_name']],
  692. ];
  693. }
  694. }
  695. // dump($where);
  696. $project_log = Db::name('ProjectLog')->where($where)
  697. ->where('project_id', $project_id)
  698. ->order('create_time', 'desc')
  699. ->select()->toArray();
  700. foreach ($project_log as $key => $value) {
  701. $project_log[$key]['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
  702. if($login_admin['user_type'] != 0){
  703. if(str($project_log[$key]['content'], '送审单位承担审核费')){
  704. unset($project_log[$key]);
  705. }
  706. if(str($project_log[$key]['content'], '施工单位负责核减超5%评审费部分')){
  707. unset($project_log[$key]);
  708. }
  709. }
  710. }
  711. $project_log = array_values($project_log);
  712. // dump($project_log);
  713. // View::assign('project_log', $project_log);
  714. // return View();
  715. return $project_log;
  716. }
  717. /**
  718. * 查看信息
  719. */
  720. public function read()
  721. {
  722. $param = get_params();
  723. $id = isset($param['id']) ? $param['id'] : 0;
  724. // dump($id);
  725. $detail = $this->model->getCostProjectById($id);
  726. $comment_type = isset($param["comment_type"])?$param['comment_type'] : 0;
  727. $comment = Db::name("project_comment")->where("type",$comment_type)
  728. ->where("project_id", $id)->order('create_time', 'asc')->select();
  729. $file_array = Db::name('ProjectFile')
  730. ->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')
  731. ->alias('mf')
  732. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  733. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  734. ->order('mf.create_time desc')
  735. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  736. ->select()->toArray();
  737. $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();
  738. $uid = Db::name("relation")->where("uuid",$id)->column("uid");
  739. $contract = Db::name("contract")->whereIn("id",$uid)
  740. ->where("subject_id",get_login_admin("unit_name"))->column("id,name,type,sign_time,sign_name");
  741. //小红点消息
  742. $red = Db::name("new_msg")->where([["uid", '=', $this->uid], ["project_id", "=", $id]])->field('detail,comment,report,user,contact')->find();
  743. if (empty($red)) {
  744. $red = ["detail" => 0, "comment" => 0, "report" => 0, "user" => 0, "contact" => 0];
  745. }
  746. //剩余时间
  747. $c = $detail['project_end_time'] - time();
  748. if ($c > 0) {
  749. $advent_time = floor($c / 86400) . "天";
  750. } else {
  751. $c = -$c;
  752. $advent_time = floor($c / 86400) . "天";
  753. }
  754. $project_log = self::project_log($id);
  755. View::assign('project_log', $project_log);
  756. // halt($project_log);
  757. // 根据用户id 查询其能显示的字段
  758. $field = $this->Field->get_field_rules_new(get_login_admin('id'));
  759. // dump($field);
  760. if (!empty($detail)) {
  761. View::assign('advent_time', $advent_time);
  762. View::assign('project_id', $id);
  763. View::assign('comment', $comment);
  764. View::assign('field', $field);
  765. View::assign('detail', $detail);
  766. View::assign('file_array', $file_array);
  767. View::assign('report', $report);
  768. View::assign('contract', $contract);
  769. View::assign('red', $red);
  770. View::assign('project_five', self::getProjectFive());
  771. // dump(self::getProjectFive());
  772. return view();
  773. } else {
  774. throw new \think\exception\HttpException(404, '找不到页面');
  775. }
  776. }
  777. /**
  778. * 删除
  779. * type=0,逻辑删除,默认
  780. * type=1,物理删除
  781. */
  782. public function del()
  783. {
  784. $param = get_params();
  785. $status = Db::name("cost_project")->where("id", $param["id"])->field("project_status")->select();
  786. if ($status[0]["project_status"] < 3) {
  787. $id = isset($param['id']) ? $param['id'] : 0;
  788. $type = isset($param['type']) ? $param['type'] : 0;
  789. add_project_log("删除项目", $id, "删除项目");
  790. $this->model->delCostProjectById($id, $type);
  791. } else {
  792. return to_assign(0, "已审核,无法删除");
  793. }
  794. }
  795. //获取客户列表
  796. public function get_customer()
  797. {
  798. $param = get_params();
  799. $where = array();
  800. if (!empty($param['keywords'])) {
  801. $where[] = ['id|title', 'like', '%' . $param['keywords'] . '%'];
  802. }
  803. $where = [
  804. ["delete_time", "=", 0],
  805. ["pid", "=", 0],
  806. ["type", "=", 2]
  807. ];
  808. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  809. $list = $this->department->field('id,title,address,leader_id')->order('id asc')->where($where)->paginate($rows, false)
  810. ->each(function ($item) {
  811. $item->nickname = Db::name('admin')->where(['id' => $item->leader_id])->value('nickname');
  812. $item->mobile = Db::name('admin')->where(['id' => $item->leader_id])->value('mobile');
  813. });
  814. // halt($list);
  815. table_assign(0, '', $list);
  816. }
  817. //获取客户列表
  818. public function addConstructionPeople()
  819. {
  820. if (request()->isAjax()) {
  821. $param = get_params();
  822. if ($param['type'] == '1') {
  823. $data = $this->model->where('id', $param['data']['id'])->find();
  824. if ($data["construction_unit"] !== null ||
  825. $data["construction_head"] !== null ||
  826. $data["construction_email"] !== null ||
  827. $data["construction_phone"] !== null
  828. ) {
  829. return to_assign(0, "已存在!!");
  830. } else {
  831. return to_assign(200, "请上传!!");
  832. }
  833. } else {
  834. $this->model->addConstructionPeople($param['data']);
  835. }
  836. add_project_log('添加施工单位人员', $param['data']['id'], '添加施工单位人员');
  837. } else {
  838. $param = get_params();
  839. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  840. //关联项目id
  841. View::assign('project_id', $project_id);
  842. return view();
  843. }
  844. }
  845. public function add_sent_review_unit()
  846. {
  847. if (request()->isAjax()) {
  848. $param = get_params();
  849. if ($param['type'] == '1') {
  850. $data = $this->model->where('id', $param['data']['id'])->find();
  851. if ($data["sent_review_unit_name"] !== null ||
  852. $data["sent_review_head_name"] !== null ||
  853. $data["sent_review_head_email"] !== null ||
  854. $data["sent_review_phone"] !== null
  855. ) {
  856. return to_assign(0, "已存在,请移除后再添加");
  857. } else {
  858. return to_assign(200, "请上传!!");
  859. }
  860. } else {
  861. add_project_log('移除送审单位成员', $param['data']['id'], $param['data']["sent_review_head_name"], 5);
  862. $this->model->addConstructionPeople($param['data']);
  863. }
  864. add_project_log('新增送审单位成员', $param['data']['id'], '新增送审单位成员');
  865. } else {
  866. $param = get_params();
  867. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  868. //关联项目id
  869. View::assign('project_id', $project_id);
  870. return view();
  871. }
  872. }
  873. //添加送审单位
  874. // public function add_sent_review_unit()
  875. // {
  876. // if (request()->isAjax()) {
  877. // $param = get_params();
  878. // $id = isset($param["id"]) ? $param["id"] : 0;
  879. // $project_id = isset($param["project_id"]) ? $param["project_id"] : 0;
  880. // $a = $this->model->where("id", $project_id)->value("sent_review_head");
  881. // if ($a) {
  882. // return to_assign(1, '已有负责人,请移除后再添加');
  883. // }
  884. // $selfData = get_admin($id);
  885. // $data = [
  886. // "id" => $project_id,
  887. // "sent_review_head" => $id,
  888. // "sent_review_head_name" => $selfData["nickname"],
  889. // "sent_review_unit" => $selfData["unit_name"],
  890. // "sent_review_unit_name" => Db::name("department")->where("id", $selfData["unit_name"])->value("title"),
  891. // "sent_review_phone" => $selfData["mobile"]
  892. // ];
  893. // try {
  894. // $this->model->update($data);
  895. // } catch (\Exception $e) {
  896. // return to_assign(1, '操作失败,原因:' . $e->getMessage());
  897. // }
  898. // add_project_log('添加送审单位成员', $project_id, $selfData["nickname"], 5);
  899. // return to_assign(0, "操作成功");
  900. // }
  901. // }
  902. //移除送审单位成员
  903. public function remove_sent_review()
  904. {
  905. $p = get_params();
  906. $project_id = isset($p["project_id"]) ? $p["project_id"] : 0;
  907. $data = [
  908. "sent_review_unit" => null,
  909. "sent_review_unit_name" => null,
  910. "sent_review_head_name" => null,
  911. "sent_review_head" => null,
  912. "sent_review_phone" => null,
  913. "sent_review_head_email" => null,
  914. ];
  915. $this->model->where("id", $project_id)->update($data);
  916. remove_user($p["id"]);
  917. add_project_log('移除送审单位成员', $project_id, $p["nickname"], 5);
  918. return to_assign(0, "操作成功");
  919. }
  920. public function project_user()
  921. {
  922. $param = get_params();
  923. $ids = $this->model->where("id", $param["project_id"])->field("entrust_maker,review_head,operate_head,operate_team")->find()->toArray();
  924. $idarr = $ids["operate_team"] . ',' . $ids["operate_head"] . ',' . $ids["review_head"] . ',' . $ids["entrust_maker"];
  925. $idarr = explode(",", $idarr);
  926. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  927. $list = $this->Adminmodel->whereIn("id", $idarr)->field("id,nickname,unit_name,mobile,email")->paginate($rows, false, ['query' => $param])
  928. // 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')
  929. ->each(function ($item) {
  930. //获取单位的邮箱,单位信息页没做
  931. $item->email = Db::name('department')->where(['id' => $item->unit_name])->value('email');
  932. $type = Db::name('department')->where(['id' => $item->unit_name])->value('type');
  933. $item->unit_name = Db::name('department')->where(['id' => $item->unit_name])->value('title');
  934. // dump($type);
  935. if ($type == 0) {
  936. $item->unit_type = "委托单位";
  937. } elseif ($type == 1) {
  938. $item->unit_type = "送审单位";
  939. } elseif ($type == 2) {
  940. $item->unit_type = "评审机构";
  941. } else {
  942. $item->unit_type = "施工单位";
  943. }
  944. })->toArray();
  945. $list = $list["data"];
  946. $time_id = time();
  947. $shigong = $this->model->where('id', $param["project_id"])->find();
  948. if ($shigong["construction_unit"] !== null ||
  949. $shigong["construction_head"] !== null ||
  950. $shigong["construction_email"] !== null ||
  951. $shigong["construction_phone"] !== null
  952. ) {
  953. $shigongdata["id"] = $time_id;
  954. $shigongdata["nickname"] = $shigong["construction_unit"];
  955. $shigongdata["unit_name"] = $shigong["construction_head"];
  956. $shigongdata["email"] = $shigong["construction_email"];
  957. $shigongdata["mobile"] = $shigong["construction_phone"];
  958. $shigongdata["unit_type"] = "施工单位";
  959. array_push($list, $shigongdata);
  960. }
  961. $time_id_sent = time()-200;
  962. if ($shigong["sent_review_unit"] !== null ||
  963. $shigong["sent_review_head"] !== null ||
  964. $shigong["sent_review_phone"] !== null ||
  965. $shigong["sent_review_head_email"] !== null
  966. ) {
  967. $sent_review_data["id"] = $time_id_sent;
  968. $sent_review_data["nickname"] = $shigong["sent_review_head_name"];
  969. $sent_review_data["unit_name"] = $shigong["sent_review_unit_name"];
  970. $sent_review_data["email"] = $shigong["sent_review_head_email"];
  971. $sent_review_data["mobile"] = $shigong["sent_review_phone"];
  972. $sent_review_data["unit_type"] = "送审单位";
  973. array_push($list, $sent_review_data);
  974. }
  975. if (empty($ids['operate_team'])) {
  976. $operate_team[] = '0';
  977. } else {
  978. $operate_team = explode(',', $ids['operate_team']);
  979. }
  980. for ($i = 0; $i < count($list); $i++) {
  981. if ($list[$i]['id'] == $ids['entrust_maker']) {
  982. // dump($list[$i]['id'],$ids['entrust_maker']);
  983. $list[$i]["type"] = 1;
  984. } elseif ($list[$i]['id'] == $ids['review_head']) {
  985. $list[$i]["type"] = 2;
  986. } elseif ($list[$i]['id'] == $ids['operate_head']) {
  987. $list[$i]["type"] = 3;
  988. } elseif (in_array($list[$i]['id'], $operate_team)) {
  989. $list[$i]["type"] = 4;
  990. } elseif ($list[$i]['id'] == $time_id) {
  991. $list[$i]["type"] = 5;
  992. } elseif ($list[$i]['id'] !== time() - 1000) {
  993. $list[$i]["type"] = 6;
  994. }
  995. }
  996. $type = array_column($list, 'type');
  997. array_multisort($type, SORT_ASC, $list);
  998. $lists["total"] = count($list);
  999. $lists["data"] = $list;
  1000. return table_assign(0, '', $lists);
  1001. }
  1002. public function remove_construction_user()
  1003. {
  1004. $p = get_params();
  1005. $data = [
  1006. "construction_unit" => null,
  1007. "construction_head" => null,
  1008. "construction_email" => null,
  1009. "construction_phone" => null
  1010. ];
  1011. $this->model->where("id", $p["project_id"])->update($data);
  1012. add_project_log('删除施工方人员', $p["project_id"], '删除施工方人员');
  1013. return to_assign(0, "操作成功");
  1014. }
  1015. public function getProjectFive()
  1016. {
  1017. $where = [
  1018. ['name', '=', '作业日志-财政局'],
  1019. ['name', '=', '工作记录-财政局'],
  1020. ['name', '=', '项目报告-财政局'],
  1021. ['name', '=', '项目人员-财政局'],
  1022. ['name', '=', '项目动态-财政局'],
  1023. ['name', '=', '项目附件-财政局'],
  1024. ['name', '=', '联系函-财政局'],
  1025. ];
  1026. $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
  1027. $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
  1028. $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
  1029. $login_rules = explode(',', $login_rules);
  1030. $rules_id = array();
  1031. foreach ($list as $key => $value) {
  1032. if ($value['name'] == "作业日志-财政局") {
  1033. if (in_array($value['id'], $login_rules)) {
  1034. $rules_id['project_comments'] = 1;
  1035. } else {
  1036. $rules_id['project_comments'] = 0;
  1037. }
  1038. } else if ($value['name'] == "工作记录-财政局") {
  1039. if (in_array($value['id'], $login_rules)) {
  1040. $rules_id['project_record'] = 1;
  1041. } else {
  1042. $rules_id['project_record'] = 0;
  1043. }
  1044. } else if ($value['name'] == "项目报告-财政局") {
  1045. if (in_array($value['id'], $login_rules)) {
  1046. $rules_id['project_report'] = 1;
  1047. } else {
  1048. $rules_id['project_report'] = 0;
  1049. }
  1050. } else if ($value['name'] == "项目人员-财政局") {
  1051. if (in_array($value['id'], $login_rules)) {
  1052. $rules_id['project_user'] = 1;
  1053. } else {
  1054. $rules_id['project_user'] = 0;
  1055. }
  1056. } else if ($value['name'] == "项目动态-财政局") {
  1057. if (in_array($value['id'], $login_rules)) {
  1058. $rules_id['project_log'] = 1;
  1059. } else {
  1060. $rules_id['project_log'] = 0;
  1061. }
  1062. } else if ($value['name'] == "项目附件-财政局") {
  1063. if (in_array($value['id'], $login_rules)) {
  1064. $rules_id['project_file'] = 1;
  1065. } else {
  1066. $rules_id['project_file'] = 0;
  1067. }
  1068. } else if ($value['name'] == "联系函-财政局") {
  1069. if (in_array($value['id'], $login_rules)) {
  1070. $rules_id['project_contact'] = 1;
  1071. } else {
  1072. $rules_id['project_contact'] = 0;
  1073. }
  1074. }
  1075. }
  1076. return $rules_id;
  1077. }
  1078. public function ceshi($id)
  1079. {
  1080. View::assign('detailId', $id);
  1081. return view();
  1082. }
  1083. }