123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace app\manage\controller;
- use think\Controller;
- use think\Db;
- use think\Session;
- use think\Config;
- use think\Cookie;
- use think\Request;
- use app\common\library\SysLogs;
- use app\common\library\UUIDs;
- class RemoteApplication extends Base {
- public function index() {
- return $this->fetch();
- }
- public function datas() {
- $page = empty($_GET["page"]) ? 1 : $_GET["page"];
- $pagesize = empty($_GET["rows"]) ? 1 : $_GET["rows"];
- if (empty($page) || $page < 1) {
- $page = 1;
- }
- if (empty($pagesize) || $pagesize < 1) {
- $pagesize = 30;
- }
- $info = DB::table('remote_application')->page($page, $pagesize)->select();
- foreach ($info as $k => $v) {
- $remote_institution = DB::table('institution')->where('id', $v['remote_institution_id'])->field('name')->find();
- $info[$k]['remote_institution_name'] = $remote_institution['name'];
- $local_institution = DB::table('institution')->where('id', $v['local_institution_id'])->field('name')->find();
- $info[$k]['local_institution_name'] = $local_institution['name'];
- $remote_doctor = DB::table('doctors')->where('id', $v['remote_doctor_id'])->field('realname')->find();
- $info[$k]['remote_doctor_name'] = $remote_doctor['realname'];
- $req_doctor = DB::table('doctors')->where('id', $v['req_doctor_id'])->field('realname')->find();
- $info[$k]['req_doctor_name'] = $req_doctor['realname'];
- }
- $num = DB::table('remote_application')->count();
- $data = array();
- $data['total'] = $num;
- $data['rows'] = $info;
- echo json_encode($data);
- }
- /**
- * 编辑窗口
- * @return type
- */
- public function edit() {
- if (isset($_GET["id"])) {
- $id = $_GET["id"];
- if ($id != null) {
- $remote_application = Db::table("remote_application")->where("id", $id)->find();
- if (count($remote_application) > 0) {
- $remote_institution = DB::table('institution')->where('id', $remote_application['remote_institution_id'])->field('name')->find();
- $remote_application['remote_institution_name'] = $remote_institution['name'];
- $local_institution = DB::table('institution')->where('id', $remote_application['local_institution_id'])->field('name')->find();
- $remote_application['local_institution_name'] = $local_institution['name'];
- $remote_doctor = DB::table('doctors')->where('id', $remote_application['remote_doctor_id'])->field('realname')->find();
- $remote_application['remote_doctor_name'] = $remote_doctor['realname'];
- $req_doctor = DB::table('doctors')->where('id', $remote_application['req_doctor_id'])->field('realname')->find();
- $remote_application['req_doctor_name'] = $req_doctor['realname'];
- $this->assign("remote_application", $remote_application);
- }
- }
- }
- return $this->fetch('edit');
- }
- public function save() {
- $a = DB::table('remote_application')->where('id', $_GET['id'])->update($_GET);
- SysLogs::log("remote_application", "U", 'id = ' . $_GET['id'] . " --> " . json_encode($_GET));
- if ($a) {
- return 'success';
- } else {
- return 'fail';
- }
- }
- /**
- * 软删除记录
- */
- public function delete() {
- if (isset($_GET["ids"])) {
- $ids = $_GET["ids"];
- if (!empty($ids)) {
- $idArr = explode(",", $ids);
- if (count($idArr) > 0) {
- Db::table("remote_application")->where("id", "in", $idArr)->update(['status' => "0"]);
- SysLogs::log("remote_application", "U", 'id in ' . $ids . " --> status = 0");
- }
- echo "delete_ok";
- return;
- }
- }
- echo "fail";
- }
- }
|