Inheritance: extends Model
コード例 #1
0
ファイル: shares.php プロジェクト: comraq/practice-work
 protected function add()
 {
     if (!isset($_SESSION['is_logged_in'])) {
         header('Location: ' . ROOT_URL . 'shares');
     }
     $viewmodel = new ShareModel();
     $this->getView($viewmodel->add(), true);
 }
コード例 #2
0
ファイル: PatientController.php プロジェクト: FlynnFang/cyfyy
 public function actionList()
 {
     //参数
     $name = Yii::app()->request->getParam("name", '');
     $hospital = Yii::app()->request->getParam("hospital", '');
     $page = Yii::app()->request->getParam("page", 1);
     // 限制医院权限
     $mHospital = $this->_userInfo['hospital'];
     $shareModel = new ShareModel();
     $shareSet = $shareModel->getTargetSetByCode($mHospital);
     $inArray = array();
     if ($shareSet) {
         $inArray = array_keys($shareSet);
     }
     $hospitalModel = new ConfigModel();
     $allHos = $hospitalModel->getSetByType(Yii::app()->params['configType']['HOSPITAL']);
     $hospitals = $allHos;
     //查询
     $c = new CDbCriteria();
     if ($this->_userInfo['role'] > 0) {
         $c->addInCondition('HOSPITAL', $inArray);
         $hospitals = array();
         foreach ($inArray as $value) {
             $hospitals[$value] = $allHos[$value];
         }
     }
     if ($name) {
         $c->addSearchCondition('NAME', $name);
     }
     if ($hospital) {
         $c->addCondition('HOSPITAL=' . $hospital);
     }
     //分页
     $start = ($page - 1) * $this->_pagesize;
     $jcxxModel = new JcxxModel();
     //总数
     $total = $jcxxModel->count($c);
     //分页
     $pages = new CPagination($total);
     $pages->pageSize = Yii::app()->params['paginavtion']['pagesize'];
     $pages->route = '/admin/patient/list';
     $pages->applyLimit($c);
     $c->order = "create_time desc";
     $list = $jcxxModel->findAll($c);
     // var_dump($list);
     // exit;
     // var_dump($list, $total);exit;
     $this->setPageTitle('病例列表');
     $this->render('list', array('list' => $list, 'pages' => $pages, 'hospitals' => $hospitals, 'shareSet' => $shareSet));
 }
コード例 #3
0
 public function actionIndex()
 {
     $this->currentMenu = '1000';
     // 获取病历总条数
     // 限制医院权限
     $mHospital = $this->_userInfo['hospital'];
     $shareModel = new ShareModel();
     $shareSet = $shareModel->getTargetSetByCode($mHospital);
     if ($shareSet) {
         $inArray = array_keys($shareSet);
     }
     $hospitalModel = new ConfigModel();
     $allHos = $hospitalModel->getSetByType(Yii::app()->params['configType']['HOSPITAL']);
     $hospitals = $allHos;
     //查询
     $c = new CDbCriteria();
     if ($this->_userInfo['role'] > 0) {
         $c->addInCondition('HOSPITAL', $inArray);
         $hospitals = array();
         foreach ($inArray as $value) {
             $hospitals[$value] = $allHos[$value];
         }
     }
     $hospitalModel = new ConfigModel();
     $hospitals = $hospitalModel->getSetByType(Yii::app()->params['configType']['HOSPITAL']);
     $jcxxModel = new JcxxModel();
     //总数
     $total = $jcxxModel->count($c);
     $totals = $jcxxModel->getPatientGroupTotal();
     $data = array();
     if ($totals) {
         foreach ($totals as $value) {
             $item = array();
             $item['value'] = $value['total'];
             $item['label'] = $hospitals[$value['hospital']];
             $item['color'] = '#F7464A';
             $item['highlight'] = '#FF5A5E';
             $data[] = $item;
         }
     }
     $this->render('index', array('userinfo' => $this->_userInfo, 'total' => $total, 'data' => json_encode($data), 'hospitals' => $hospitals));
 }
コード例 #4
0
 public function actionUpdate()
 {
     $op = Yii::app()->request->getParam('op', '');
     $id = Yii::app()->request->getPost('id', '');
     $code = Yii::app()->request->getPost("code", '');
     $name = Yii::app()->request->getPost("name", '');
     if (!$name || !$code) {
         $this->_output(-1, '参数错误');
     }
     $configModel = new ConfigModel();
     $configModel['type'] = Yii::app()->params['configType']['HOSPITAL'];
     $configModel['c_key'] = $code;
     $configModel['c_value'] = $name;
     $hospitalModel = new ConfigModel();
     $hospitals = $hospitalModel->getSetByType(Yii::app()->params['configType']['HOSPITAL']);
     //共享
     $shares = array();
     $my = new ShareModel();
     $my->setIsNewRecord(1);
     $my['hospital'] = $code;
     $my['target_hospital'] = $code;
     $my['permission'] = join(',', array_keys(Yii::app()->params['permission']));
     $shares[$code] = $my;
     foreach ($hospitals as $key => $value) {
         $permission = Yii::app()->request->getPost('permission_' . $key, '');
         if ($permission) {
             $item = new ShareModel();
             $item->setIsNewRecord(1);
             $item['hospital'] = $code;
             $item['target_hospital'] = $key;
             $item['permission'] = join(',', $permission);
             $shares[$key] = $item;
         }
     }
     //更新
     if ($op == 'edit' && $id && ($hospital = $configModel->getModel($configModel['type'], $code))) {
         $configModel['id'] = $hospital['id'];
         $configModel->update();
     }
     // 新增
     if ($op == 'add') {
         $configModel->setIsNewRecord(1);
         $configModel->save();
     }
     $shareModel = new ShareModel();
     $shareModel->deleteByHospital($code);
     $shareModel->saveMany($shares);
     $this->redirect(Yii::app()->getBaseUrl() . "/admin/hospital/list");
 }
コード例 #5
0
ファイル: Share.php プロジェクト: derek-chow/YunYinService
 /**
  * 搜索
  * @method GET_searchAction
  * @todo 标签
  * @author NewFuture
  */
 public function GET_searchAction()
 {
     Input::get('page', $page, 'int', 1);
     $Share = ShareModel::page($page)->field('id,name,time');
     if (Input::get('key', $key)) {
         $key = '%' . strtr($key, ' ', '%') . '%';
         $Share = where('name', 'LIKE', $key)->orWhere('detail', 'LIKE', $key);
     }
     if (Input::get('key', $tag, 'int')) {
         //标签筛选
     }
     $shares = $Share->select();
     $this->response(1, $shares);
 }