CostProprietor.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  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\ProjectFile;
  10. use think\facade\Db;
  11. use think\facade\View;
  12. use think\App;
  13. use app\admin\controller\field\Fieldproprietor;
  14. class CostProprietor extends BaseController
  15. {
  16. private array $field_name = [
  17. 'project_num' => '项目编号',
  18. "project_name" => "项目名称",
  19. "project_start_time" => "项目开始时间",
  20. "project_end_time" => "项目结束时间",
  21. "review_unit" => "评审单位",
  22. "sent_review_unit" => "送审单位",
  23. "sent_review_head" => "送审单位负责人",
  24. "sent_review_phone" => "送审单位负责人电话",
  25. "construction_unit" => "施工单位",
  26. "construction_head" => "施工单位负责人",
  27. "construction_phone" => "施工单位负责人电话",
  28. "sent_review_amount" => "送审金额",
  29. "engineering_type" => '工程类型',
  30. ];
  31. /**
  32. * 构造函数
  33. */
  34. public function __construct(App $app)
  35. {
  36. parent::__construct($app);
  37. $this->Field = new Fieldproprietor($this->app);
  38. $this->department = new DepartmentModel();
  39. $this->model = new CostProjectModel();
  40. $this->filemodel = new ProjectFile();
  41. $this->uid = get_login_admin('id');
  42. $this->Adminmodel = new Admin();
  43. }
  44. /**
  45. * 数据列表
  46. */
  47. public function datalist()
  48. {
  49. if (request()->isAjax()) {
  50. $param = get_params();
  51. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  52. $order = empty($param['order']) ? 'id desc' : $param['order'];
  53. if (isset($param["project_start_time"])) {
  54. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  55. }
  56. if (isset($param["project_end_time"])) {
  57. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  58. }
  59. if (!empty($param['project_status'])) {
  60. $where[] = ['project_status', '=', $param['project_status']];
  61. }
  62. if (!empty($param['province'])) {
  63. $where[] = ['province', '=', $param['province']];
  64. }
  65. if (!empty($param['city'])) {
  66. $where[] = ['city', '=', $param['city']];
  67. }
  68. if (!empty($param['area'])) {
  69. $where[] = ['area', '=', $param['area']];
  70. }
  71. if (!empty($param['project_end_time'])) {
  72. $where[] = ['project_end_time', '<', $param['project_end_time']];
  73. }
  74. if (!empty($param['project_start_time'])) {
  75. $where[] = ['project_start_time', '>', $param['project_start_time']];
  76. }
  77. if (!empty($param['review_head_name'])) {
  78. $where[] = ['review_head_name', 'like', '%' . $param['review_head_name'] . '%'];
  79. }
  80. if (!empty($param['review_unit_name'])) {
  81. $where[] = ['review_unit_name', 'like', '%' . $param['review_unit_name']. '%'];
  82. }
  83. if (!empty($param['sent_review_unit_name'])) {
  84. $where[] = ['sent_review_unit_name', 'like', '%' . $param['sent_review_unit_name']. '%'];
  85. }
  86. if (!empty($param['project_name'])) {
  87. $where[] = ['project_name', 'like', '%' . $param['project_name'] . '%'];
  88. }
  89. $where3 =[];
  90. if (!empty($param['keyword'])) {
  91. $keyword = $param['keyword'];
  92. $where3[] = ['project_num|project_name|review_unit', 'like', '%' . $keyword . '%'];
  93. }
  94. //项目可见的权限
  95. $field = $this->Field->get_field_rules_new($this->uid);
  96. //1全部-可查看可编辑,2全部-可查看,0与我有关
  97. $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
  98. if($see_auth==0 || $see_auth==3){
  99. $where[] =["delete_time", "=", 0];
  100. $where[] =["sent_review_unit", "=", get_login_admin("unit_name")];
  101. $where[] =["sent_review_head","=",$this->uid];
  102. }else{
  103. $where[] =["delete_time", "=", 0];
  104. $where[] =["sent_review_unit", "=", get_login_admin("unit_name")];
  105. }
  106. $this->see_auth = $see_auth;
  107. $list = $this->model->where($where)->where($where3)->order($order)->paginate($rows, false, ['query' => $param])
  108. ->each(function ($item) {
  109. $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
  110. if ($red) {
  111. if ($red["detail"] || $red["comment"] || $red["report"] || $red["user"] || $red["contact"]) {
  112. $item->red = 1;
  113. }
  114. } else {
  115. $item->red = 0;
  116. }
  117. if (($item->province && $item->city && $item->area)) {
  118. $item->project_region = $item->province . '-' . $item->city . '-' . $item->area;
  119. }
  120. $item->self_id = $this->see_auth;
  121. //作业人
  122. $operate_team_names = null;
  123. $operate_team_names_ids = explode(",", $item->operate_team);
  124. for ($i = 0; $i < count($operate_team_names_ids); $i++) {
  125. $name = Db::name("admin")->where("id", $operate_team_names_ids[$i])->value("nickname");
  126. if (!($i == 0)) {
  127. $name = "," . $name;
  128. }
  129. $operate_team_names = $operate_team_names . $name;
  130. }
  131. $item->operate_team_names = $operate_team_names;
  132. });
  133. return table_assign(0, '', $list);
  134. } else {
  135. $field = $this->Field->get_field_rules($this->uid);
  136. // halt($field);
  137. View::assign('field', $field);
  138. return view();
  139. }
  140. }
  141. //TODO
  142. public function list()
  143. {
  144. // if (request()->isAjax()) {
  145. $param = get_params();
  146. strtotime('-10 days');
  147. // halt(strtotime('-10 days'));
  148. $where = [
  149. ["delete_time", "=", 0],
  150. ["entrust_maker", "=", $this->uid],
  151. ['project_end_time', '<', strtotime('15 days')],
  152. ['project_end_time', '>', time()],
  153. ["project_status", "<", 7],
  154. ["project_status", ">", 3]
  155. ];
  156. $where2 = [
  157. ["delete_time", "=", 0],
  158. ["entrust_approver", "=", $this->uid],
  159. ['project_end_time', '<', strtotime('15 days')],
  160. ['project_end_time', '>', time()],
  161. ["project_status", "<", 7],
  162. ["project_status", ">", 3]
  163. ];
  164. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  165. $order = empty($param['order']) ? 'id desc' : $param['order'];
  166. $list = $this->model->whereOr([$where, $where2])
  167. ->order($order)
  168. ->paginate($rows, false, ['query' => $param])
  169. ->each(function ($item) {
  170. });
  171. // halt($list);
  172. return table_assign(0, '', $list);
  173. // }
  174. }
  175. public function list2()
  176. {
  177. // if (request()->isAjax()) {
  178. $param = get_params();
  179. strtotime('-10 days');
  180. // halt(strtotime('-10 days'));
  181. $where = [
  182. ["delete_time", "=", 0],
  183. ["entrust_maker", "=", $this->uid],
  184. ['project_end_time', '<', time()],
  185. ["project_status", "<", 7],
  186. ["project_status", ">", 3]
  187. ];
  188. $where2 = [
  189. ["delete_time", "=", 0],
  190. ["entrust_approver", "=", $this->uid],
  191. ['project_end_time', '<', time()],
  192. ["project_status", "<", 7],
  193. ["project_status", ">", 3]
  194. ];
  195. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  196. $order = empty($param['order']) ? 'id desc' : $param['order'];
  197. $list = $this->model->whereOr([$where, $where2])
  198. ->order($order)->paginate($rows, false, ['query' => $param])
  199. ->each(function ($item) {
  200. });
  201. // halt($list);
  202. return table_assign(0, '', $list);
  203. // }
  204. }
  205. /**
  206. * 业主建立项目
  207. */
  208. public function add()
  209. {
  210. if (request()->isAjax()) {
  211. $param = get_params();
  212. if (isset($param["project_start_time"])) {
  213. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  214. }
  215. if (isset($param["project_end_time"])) {
  216. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  217. }
  218. $param["sent_review_unit"] = get_login_admin("unit_name");
  219. $param["sent_review_unit_name"] = Db::name("department")->where("id", get_login_admin("unit_name"))->value("title");
  220. $param["sent_review_head"] = $this->uid;
  221. $param["sent_review_head_name"] = get_login_admin("nickname");
  222. $param["sent_review_head_phone"] = get_login_admin("mobile");
  223. $param["project_status"] = 0;
  224. //0:财政局,1:业主,2:公司
  225. $param["maker_type"] = 1;
  226. $file_ids = isset($param["file_ids"]) ? $param["file_ids"] : 0;
  227. unset($param["file_ids"]);
  228. $file_id = [];
  229. $insertId = 0;
  230. try {
  231. $param['create_time'] = time();
  232. $insertId = $this->model->strict(false)->field(true)->insertGetId($param);
  233. if ($file_ids) {
  234. for ($a = 0; $a < count($file_ids); $a++) {
  235. $file_id[] = ["id" => $file_ids[$a], "topic_id" => $insertId];
  236. }
  237. $this->filemodel->saveAll($file_id);
  238. }
  239. add_log('add', $insertId, $param);
  240. add_project_log("创建项目", $insertId, "创建项目");
  241. add_user($param["sent_review_head"], $insertId);
  242. } catch (\Exception $e) {
  243. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  244. }
  245. return to_assign(0, '操作成功', ['aid' => $insertId]);
  246. } else {
  247. $person = Db::name("admin")->where("unit_name", get_login_admin("unit_name"))->where("status",">",0)->field(["id", "nickname"])->select()->toArray();
  248. View::assign("person", $person);
  249. return view();
  250. }
  251. }
  252. /**
  253. * 业主建立项目
  254. */
  255. public function save()
  256. {
  257. if (request()->isAjax()) {
  258. $param = get_params();
  259. $id = $param["id"] ?? 0;
  260. if (isset($param["project_start_time"])) {
  261. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  262. }
  263. if (isset($param["project_end_time"])) {
  264. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  265. }
  266. $param["sent_review_unit"] = get_login_admin("unit_name");
  267. $param["sent_review_unit_name"] = Db::name("department")->where("id", get_login_admin("unit_name"))->value("title");
  268. $param["sent_review_head"] = $this->uid;
  269. $param["sent_review_head_name"] = get_login_admin("nickname");
  270. $param["sent_review_head_phone"] = get_login_admin("mobile");
  271. $param["project_status"] = 0;
  272. $param["proprietor_status"] = 1;
  273. //0:财政局,1:业主,2:公司
  274. $param["maker_type"] = 1;
  275. $file_ids = isset($param["file_ids"]) ? $param["file_ids"] : 0;
  276. unset($param["file_ids"]);
  277. $file_id = [];
  278. try {
  279. $param['create_time'] = time();
  280. if($id==0){
  281. $insertId = $this->model->strict(false)->field(true)->insertGetId($param);
  282. }else{
  283. $this->model->where("id",$id)->update($param);
  284. $insertId = $id;
  285. }
  286. if ($file_ids) {
  287. for ($a = 0; $a < count($file_ids); $a++) {
  288. $file_id[] = ["id" => $file_ids[$a], "topic_id" => $insertId];
  289. }
  290. $this->filemodel->saveAll($file_id);
  291. }
  292. $auditData = [
  293. "project_id" => $insertId,
  294. "project_name" => $param["project_name"],
  295. "project_type" => "造价项目",
  296. "audit_name" => "项目立项审核",
  297. "audit_type" => 16,//业主审核
  298. "sponsor" => get_login_admin("nickname"),
  299. "sponsor_id" => $this->uid,
  300. "sponsor_unit" => Db::name("department")->where("id",get_login_admin("unit_name"))->value("title"),
  301. "approver" => $param["sent_review_approver"],
  302. "approver_name" => Db::name('admin')->where("id", $param["sent_review_approver"])->value("nickname"),
  303. "create_time" => time()
  304. ];
  305. ProjectAudit::create($auditData);
  306. add_log('add', $insertId, $param);
  307. add_project_log("创建项目", $insertId, "创建项目");
  308. add_user($param["sent_review_head"], $insertId);
  309. } catch (\Exception $e) {
  310. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  311. }
  312. return to_assign(0, '操作成功', ['aid' => $insertId]);
  313. } else {
  314. $person = Db::name("admin")->where("unit_name", get_login_admin("unit_name"))->where("status",">",0)->field(["id", "nickname"])->select()->toArray();
  315. View::assign("person", $person);
  316. return view();
  317. }
  318. }
  319. public function edit(){
  320. $param = get_params();
  321. $type = isset($param["type"])??0;
  322. if(request()->isAjax()&&$type!=2){
  323. $param = get_params();
  324. $id = $param["id"] ?? 0;
  325. if (isset($param["project_start_time"])) {
  326. $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
  327. }
  328. if (isset($param["project_end_time"])) {
  329. $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
  330. }
  331. $param["sent_review_unit"] = get_login_admin("unit_name");
  332. $param["sent_review_unit_name"] = Db::name("department")->where("id", get_login_admin("unit_name"))->value("title");
  333. $param["sent_review_head"] = $this->uid;
  334. $param["sent_review_head_name"] = get_login_admin("nickname");
  335. $param["sent_review_head_phone"] = get_login_admin("mobile");
  336. $param["project_status"] = 0;
  337. //0:财政局,1:业主,2:公司
  338. $param["maker_type"] = 1;
  339. $file_ids = isset($param["file_ids"]) ? $param["file_ids"] : 0;
  340. unset($param["file_ids"]);
  341. $file_id = [];
  342. try {
  343. $param['create_time'] = time();
  344. $this->model->where("id",$id)->update($param);
  345. $insertId = $id;
  346. if ($file_ids) {
  347. for ($a = 0; $a < count($file_ids); $a++) {
  348. $file_id[] = ["id" => $file_ids[$a], "topic_id" => $insertId];
  349. }
  350. $this->filemodel->saveAll($file_id);
  351. }
  352. add_log('add', $insertId, $param);
  353. add_project_log("编辑项目", $insertId, "编辑项目");
  354. } catch (\Exception $e) {
  355. return to_assign(1, '操作失败,原因:' . $e->getMessage());
  356. }
  357. return to_assign(0, '操作成功', ['aid' => $insertId]);
  358. }else{
  359. $param = get_params();
  360. $id = $param['id'] ?? 0;
  361. $detail = $this->model->getCostProjectById($id);
  362. $person = Db::name("admin")->where("unit_name", get_login_admin("unit_name"))->where("status",">",0)->field(["id", "nickname"])->select()->toArray();
  363. $file_array = Db::name('ProjectFile')
  364. ->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')
  365. ->alias('mf')
  366. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  367. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  368. ->order('mf.create_time desc')
  369. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  370. ->select()->toArray();
  371. if (!empty($detail)) {
  372. View::assign('project_id', $id);
  373. View::assign('detail', $detail);
  374. View::assign("person", $person);
  375. View::assign("file_array", $file_array);
  376. View::assign('project_five', self::getProjectFive());
  377. } else {
  378. throw new \think\exception\HttpException(404, '找不到页面,请联系管理员');
  379. }
  380. return view();
  381. }
  382. }
  383. /**
  384. * 查看信息
  385. */
  386. public function read()
  387. {
  388. $param = get_params();
  389. $id = isset($param['id']) ? $param['id'] : 0;
  390. // dump($id);
  391. $detail = $this->model->getCostProjectById($id);
  392. $comment_type = isset($param["comment_type"])?$param['comment_type'] : 0;
  393. $comment = Db::name("project_comment")->where("type",$comment_type)
  394. ->where("project_id", $id)->order('create_time', 'asc')->select();
  395. $file_array = Db::name('ProjectFile')
  396. ->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')
  397. ->alias('mf')
  398. ->join('File f', 'mf.file_id = f.id', 'LEFT')
  399. ->join('Admin a', 'mf.admin_id = a.id', 'LEFT')
  400. ->order('mf.create_time desc')
  401. ->where(array('mf.topic_id' => $id, 'mf.module' => 'project'))
  402. ->select()->toArray();
  403. $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();
  404. // halt($comment);
  405. $project_log = self::project_log($id);
  406. View::assign('project_log', $project_log);
  407. // halt($project_log);
  408. // 根据用户id 查询其能显示的字段
  409. $field = $this->Field->get_field_rules_new(get_login_admin('id'));
  410. // dump($field);
  411. // halt(self::getProjectFive());
  412. if (!empty($detail)) {
  413. View::assign('project_id', $id);
  414. View::assign('comment', $comment);
  415. View::assign('field', $field);
  416. View::assign('detail', $detail);
  417. View::assign('file_array', $file_array);
  418. View::assign('report', $report);
  419. View::assign('project_five', self::getProjectFive());
  420. return view();
  421. } else {
  422. throw new \think\exception\HttpException(404, '找不到页面');
  423. }
  424. }
  425. //获取客户列表
  426. public function get_customer()
  427. {
  428. $param = get_params();
  429. $where = array();
  430. if (!empty($param['keywords'])) {
  431. $where[] = ['id|title', 'like', '%' . $param['keywords'] . '%'];
  432. }
  433. $where = [
  434. ["delete_time", "=", 0],
  435. ["pid", "=", 0],
  436. ["type", "=", 2]
  437. ];
  438. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  439. $list = $this->department->field('id,title,address,leader_id')->order('id asc')->where($where)->paginate($rows, false)
  440. ->each(function ($item) {
  441. $item->nickname = Db::name('admin')->where(['id' => $item->leader_id])->value('nickname');
  442. $item->mobile = Db::name('admin')->where(['id' => $item->leader_id])->value('mobile');
  443. });
  444. // halt($list);
  445. table_assign(0, '', $list);
  446. }
  447. //获取客户列表
  448. public function addConstructionPeople()
  449. {
  450. $param = get_params();
  451. if (request()->isAjax()) {
  452. $this->model->addConstructionPeople($param);
  453. } else {
  454. $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
  455. //关联项目id
  456. View::assign('project_id', $project_id);
  457. return view();
  458. }
  459. }
  460. public function getConstructionPeople()
  461. {
  462. $param = get_params();
  463. if (request()->isAjax()) {
  464. $data = $this->model->where('id', $param["id"])->find();
  465. if ($data["construction_unit"] !== null ||
  466. $data["construction_head"] !== null ||
  467. $data["construction_email"] !== null ||
  468. $data["construction_phone"] !== null
  469. ) {
  470. return to_assign(0, "已存在!!");
  471. } else {
  472. return to_assign(200, "请上传!!");
  473. }
  474. }
  475. }
  476. public function project_user()
  477. {
  478. $param = get_params();
  479. $ids = $this->model->where("id", $param["project_id"])->field("entrust_maker,review_head,operate_head,operate_team")->find()->toArray();
  480. $idarr = $ids["operate_team"] . ',' . $ids["operate_head"] . ',' . $ids["review_head"] . ',' . $ids["entrust_maker"];
  481. $idarr = explode(",", $idarr);
  482. $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
  483. $list = $this->Adminmodel->whereIn("id", $idarr)->field("id,nickname,unit_name,mobile,email")->paginate($rows, false, ['query' => $param])
  484. // 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')
  485. ->each(function ($item) {
  486. //获取单位的邮箱,单位信息页没做
  487. $item->email = Db::name('department')->where(['id' => $item->unit_name])->value('email');
  488. $type = Db::name('department')->where(['id' => $item->unit_name])->value('type');
  489. $item->unit_name = Db::name('department')->where(['id' => $item->unit_name])->value('title');
  490. // dump($type);
  491. if ($type == 0) {
  492. $item->unit_type = "委托单位";
  493. } elseif ($type == 1) {
  494. $item->unit_type = "送审单位";
  495. } elseif ($type == 2) {
  496. $item->unit_type = "评审机构";
  497. } else {
  498. $item->unit_type = "施工单位";
  499. }
  500. })->toArray();
  501. $list = $list["data"];
  502. for ($i = 0; $i < count($list); $i++) {
  503. if ($list[$i]['id'] == $ids['entrust_maker']) {
  504. // dump($list[$i]['id'],$ids['entrust_maker']);
  505. $list[$i]["type"] = 1;
  506. } elseif ($list[$i]['id'] == $ids['review_head']) {
  507. $list[$i]["type"] = 2;
  508. } elseif ($list[$i]['id'] == $ids['operate_head']) {
  509. $list[$i]["type"] = 3;
  510. } elseif (in_array($list[$i]['id'], explode(',', $ids['operate_team']))) {
  511. $list[$i]["type"] = 4;
  512. }
  513. }
  514. $type = array_column($list, 'type');
  515. array_multisort($type, SORT_ASC, $list);
  516. $shigong = $this->model->where('id', $param["project_id"])->find();
  517. if ($shigong["construction_unit"] !== null ||
  518. $shigong["construction_head"] !== null ||
  519. $shigong["construction_email"] !== null ||
  520. $shigong["construction_phone"] !== null
  521. ) {
  522. $shigongdata["id"] = time();
  523. $shigongdata["nickname"] = $shigong["construction_unit"];
  524. $shigongdata["unit_name"] = $shigong["construction_head"];
  525. $shigongdata["email"] = $shigong["construction_email"];
  526. $shigongdata["mobile"] = $shigong["construction_phone"];
  527. $shigongdata["unit_type"] = "施工单位";
  528. array_push($list, $shigongdata);
  529. }
  530. $list["data"] = $list;
  531. return table_assign(0, '', $list);
  532. }
  533. public function getProjectFive()
  534. {
  535. $where = [
  536. ['name', '=', '作业日志-业主'],
  537. ['name', '=', '工作记录-业主'],
  538. ['name', '=', '项目报告-业主'],
  539. ['name', '=', '项目人员-业主'],
  540. ['name', '=', '项目动态-业主'],
  541. ['name', '=', '项目附件-业主'],
  542. ['name', '=', '联系函-业主'],
  543. ];
  544. $list = Db::name('AdminRule')->whereOr($where)->field('id,name')->select()->toArray();
  545. $group_id = Db::name('AdminGroupAccess')->where('uid', get_login_admin('id'))->value('group_id');
  546. $login_rules = Db::name('AdminGroup')->where('id', $group_id)->value('rules');
  547. $login_rules = explode(',', $login_rules);
  548. $rules_id = array();
  549. foreach ($list as $key => $value) {
  550. if ($value['name'] == "作业日志-业主") {
  551. if (in_array($value['id'], $login_rules)) {
  552. $rules_id['project_comments'] = 1;
  553. } else {
  554. $rules_id['project_comments'] = 0;
  555. }
  556. } else if ($value['name'] == "工作记录-业主") {
  557. if (in_array($value['id'], $login_rules)) {
  558. $rules_id['project_record'] = 1;
  559. } else {
  560. $rules_id['project_record'] = 0;
  561. }
  562. } else if ($value['name'] == "项目报告-业主") {
  563. if (in_array($value['id'], $login_rules)) {
  564. $rules_id['project_report'] = 1;
  565. } else {
  566. $rules_id['project_report'] = 0;
  567. }
  568. } else if ($value['name'] == "项目人员-业主") {
  569. if (in_array($value['id'], $login_rules)) {
  570. $rules_id['project_user'] = 1;
  571. } else {
  572. $rules_id['project_user'] = 0;
  573. }
  574. } else if ($value['name'] == "项目动态-业主") {
  575. if (in_array($value['id'], $login_rules)) {
  576. $rules_id['project_log'] = 1;
  577. } else {
  578. $rules_id['project_log'] = 0;
  579. }
  580. } else if ($value['name'] == "项目附件-业主") {
  581. if (in_array($value['id'], $login_rules)) {
  582. $rules_id['project_file'] = 1;
  583. } else {
  584. $rules_id['project_file'] = 0;
  585. }
  586. } else if ($value['name'] == "联系函-业主") {
  587. if (in_array($value['id'], $login_rules)) {
  588. $rules_id['project_contact'] = 1;
  589. } else {
  590. $rules_id['project_contact'] = 0;
  591. }
  592. }
  593. }
  594. return $rules_id;
  595. }
  596. public function getemployeelist()
  597. {
  598. if (request()->isAjax()) {
  599. $data = $this->request->param();
  600. $person = Db::name("admin")->where([["unit_name", "=", $data['id']], ["status", "=", 1]])->field(["id", "nickname", "mobile"])->select();
  601. return $person;
  602. }
  603. }
  604. public function project_log($project_id)
  605. {
  606. // $project_id = 24;
  607. $login_admin = get_login_admin();
  608. $where = array();
  609. if ($login_admin['user_type'] == 2) {
  610. $where = [
  611. ['project_status', '>=', 3],
  612. ['unit_name', '=', $login_admin['unit_name']],
  613. ];
  614. } else {
  615. if ($login_admin['permission'] != 1) {
  616. $where = [
  617. ['unit_name', '=', $login_admin['unit_name']],
  618. ];
  619. }
  620. }
  621. // dump($where);
  622. $project_log = Db::name('ProjectLog')->where($where)->where('project_id', $project_id)->order('create_time', 'desc')->select()->toArray();
  623. foreach ($project_log as $key => $value) {
  624. $project_log[$key]['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
  625. }
  626. // dump($project_log);
  627. // View::assign('project_log', $project_log);
  628. // return View();
  629. return $project_log;
  630. }
  631. }