Temporary.php 42 KB

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