Remoteapplication.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace app\manage\controller;
  3. use think\Controller;
  4. use think\Db;
  5. use think\Session;
  6. use think\Config;
  7. use think\Cookie;
  8. use think\Request;
  9. use app\common\library\SysLogs;
  10. use app\common\library\UUIDs;
  11. class RemoteApplication extends Base {
  12. public function index() {
  13. return $this->fetch();
  14. }
  15. public function datas() {
  16. $page = empty($_GET["page"]) ? 1 : $_GET["page"];
  17. $pagesize = empty($_GET["rows"]) ? 1 : $_GET["rows"];
  18. if (empty($page) || $page < 1) {
  19. $page = 1;
  20. }
  21. if (empty($pagesize) || $pagesize < 1) {
  22. $pagesize = 30;
  23. }
  24. $info = DB::table('remote_application')->page($page, $pagesize)->select();
  25. foreach ($info as $k => $v) {
  26. $remote_institution = DB::table('institution')->where('id', $v['remote_institution_id'])->field('name')->find();
  27. $info[$k]['remote_institution_name'] = $remote_institution['name'];
  28. $local_institution = DB::table('institution')->where('id', $v['local_institution_id'])->field('name')->find();
  29. $info[$k]['local_institution_name'] = $local_institution['name'];
  30. $remote_doctor = DB::table('doctors')->where('id', $v['remote_doctor_id'])->field('realname')->find();
  31. $info[$k]['remote_doctor_name'] = $remote_doctor['realname'];
  32. $req_doctor = DB::table('doctors')->where('id', $v['req_doctor_id'])->field('realname')->find();
  33. $info[$k]['req_doctor_name'] = $req_doctor['realname'];
  34. }
  35. $num = DB::table('remote_application')->count();
  36. $data = array();
  37. $data['total'] = $num;
  38. $data['rows'] = $info;
  39. echo json_encode($data);
  40. }
  41. /**
  42. * 编辑窗口
  43. * @return type
  44. */
  45. public function edit() {
  46. if (isset($_GET["id"])) {
  47. $id = $_GET["id"];
  48. if ($id != null) {
  49. $remote_application = Db::table("remote_application")->where("id", $id)->find();
  50. if (count($remote_application) > 0) {
  51. $remote_institution = DB::table('institution')->where('id', $remote_application['remote_institution_id'])->field('name')->find();
  52. $remote_application['remote_institution_name'] = $remote_institution['name'];
  53. $local_institution = DB::table('institution')->where('id', $remote_application['local_institution_id'])->field('name')->find();
  54. $remote_application['local_institution_name'] = $local_institution['name'];
  55. $remote_doctor = DB::table('doctors')->where('id', $remote_application['remote_doctor_id'])->field('realname')->find();
  56. $remote_application['remote_doctor_name'] = $remote_doctor['realname'];
  57. $req_doctor = DB::table('doctors')->where('id', $remote_application['req_doctor_id'])->field('realname')->find();
  58. $remote_application['req_doctor_name'] = $req_doctor['realname'];
  59. $this->assign("remote_application", $remote_application);
  60. }
  61. }
  62. }
  63. return $this->fetch('edit');
  64. }
  65. public function save() {
  66. $a = DB::table('remote_application')->where('id', $_GET['id'])->update($_GET);
  67. SysLogs::log("remote_application", "U", 'id = ' . $_GET['id'] . " --> " . json_encode($_GET));
  68. if ($a) {
  69. return 'success';
  70. } else {
  71. return 'fail';
  72. }
  73. }
  74. /**
  75. * 软删除记录
  76. */
  77. public function delete() {
  78. if (isset($_GET["ids"])) {
  79. $ids = $_GET["ids"];
  80. if (!empty($ids)) {
  81. $idArr = explode(",", $ids);
  82. if (count($idArr) > 0) {
  83. Db::table("remote_application")->where("id", "in", $idArr)->update(['status' => "0"]);
  84. SysLogs::log("remote_application", "U", 'id in ' . $ids . " --> status = 0");
  85. }
  86. echo "delete_ok";
  87. return;
  88. }
  89. }
  90. echo "fail";
  91. }
  92. }