Example #1
0
 public function testGetUserByPhoneAndDeleteUserById()
 {
     $table = new UserModel();
     $ret = $table->getUserByPhone('333333');
     $this->assertTrue($ret['nickname'] == '王五');
     $beforeTotal = $table->field('COUNT(*) as total')->find();
     $table->deleteById($ret['id']);
     $afterTotal = $table->field('COUNT(*) as total')->find();
     $this->assertTrue(1 == $beforeTotal['total'] - $afterTotal['total']);
 }
Example #2
0
 public function indexAction()
 {
     $p = $_REQUEST;
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pNewptxt = empty($p['newptxt']) ? '' : trim($p['newptxt']);
     $pCode = empty($p['code']) ? '' : intval(trim($p['code']));
     $tTime = time();
     if (empty($pPhone)) {
         Tool_Fnc::ajaxMsg('请输入手机号码');
     }
     if (empty($pNewptxt)) {
         Tool_Fnc::ajaxMsg('请输入新密码');
     }
     if (!Tool_Validate::mo($pPhone)) {
         Tool_Fnc::ajaxMsg('手机号不正确');
     }
     $tMO = new UserModel();
     $tRow = $tMO->field('*')->where('phone = \'' . $pPhone . '\'')->fRow();
     if (empty($tRow['id'])) {
         Tool_Fnc::ajaxMsg('用户不存在');
     }
     $tCodeMO = new PhonecodeModel();
     $tCodeCRow = $tCodeMO->check($pPhone, 2, $pCode);
     if ($tCodeCRow['status'] == 0) {
         Tool_Fnc::ajaxMsg($tCodeCRow['msg']);
     }
     $tKey = Tool_Fnc::newrand(4);
     $tMd5str = Tool_Fnc::markmd5($pNewptxt, $tKey);
     $tData = array('passwd' => $tMd5str, 'id' => $tRow['id'], 'private_key' => $tKey);
     if ($tMO->update($tData)) {
         Tool_Fnc::ajaxMsg('密码修改成功', 1);
     }
     Tool_Fnc::ajaxMsg('密码修改失败');
 }
Example #3
0
 /**
  * 验证token
  * @method checkToken
  * @param  [type]     $uid   [description]
  * @param  [type]     $token [description]
  * @return [type]            [description]
  * @author NewFuture
  */
 public static function checkToken($uid, $token)
 {
     if ($user = UserModel::field('id,number,password,sch_id')->find(intval($uid))->get()) {
         $base_token = self::createBaseToken($user);
         return $token == $base_token ? $user : null;
     }
 }
Example #4
0
 public function editAction()
 {
     $p = $_REQUEST;
     $pWeight = empty($p['weight']) ? Tool_Fnc::ajaxMsg('干体重不能为空') : floatval($p['weight']);
     $tTime = time();
     $tDWLMO = new DryweightlogModel();
     $tDWLRow = $tDWLMO->field('id')->where('uid = ' . $this->tUid . ' and date = \'' . date('Y-m-d', $tTime) . '\'')->fRow();
     $tUMO = new UserModel();
     $tURow = $tUMO->field('user_type')->where(' id = ' . $this->tUid)->fRow();
     if ($tURow['user_type'] == 1) {
         Tool_Fnc::ajaxMsg('操作异常');
     }
     $tData = array('weight' => $pWeight);
     if (empty($tDWLRow['id'])) {
         $tData = array_merge($tData, array('created' => $tTime, 'uid' => $this->tUid, 'date' => date('Y-m-d', $tTime), 'year' => date('Y', $tTime), 'month' => date('Y-m', $tTime)));
     } else {
         $tData = array_merge($tData, array('updated' => $tTime, 'id' => $tDWLRow['id']));
     }
     $tUMO->begin();
     if (!$tDWLMO->save($tData)) {
         $tUMO->back();
         Tool_Fnc::ajaxMsg('修改失败 001');
     }
     $tUData = array('id' => $this->tUid, 'dry_weight' => $pWeight, 'updated' => $tTime);
     if (!$tUMO->update($tUData)) {
         $tUMO->back();
         Tool_Fnc::ajaxMsg('修改失败 002');
     }
     $tUMO->commit();
     Tool_Fnc::ajaxMsg('操作成功', 1);
 }
Example #5
0
 public function indexAction()
 {
     $p = $_REQUEST;
     $pNewptxt = empty($p['newptxt']) ? '' : trim($p['newptxt']);
     $pOldptxt = empty($p['oldptxt']) ? '' : trim($p['oldptxt']);
     $tTime = time();
     if (empty($pOldptxt)) {
         Tool_Fnc::ajaxMsg('请输入旧密码');
     }
     if (empty($pNewptxt)) {
         Tool_Fnc::ajaxMsg('请输入新密码');
     }
     $tUMO = new UserModel();
     $tRow = $tUMO->field('id,passwd,private_key')->where('id = ' . $this->tUid)->fRow();
     if (!count($tRow)) {
         Tool_Fnc::ajaxMsg('读取信息失败');
     }
     $tOldptxt = Tool_Fnc::markmd5($pOldptxt, $tRow['private_key']);
     if ($tRow['passwd'] != $tOldptxt) {
         Tool_Fnc::ajaxMsg('旧密码不正确');
     }
     $tKey = Tool_Fnc::newrand(4);
     $tMd5str = Tool_Fnc::markmd5($pNewptxt, $tKey);
     $tData = array('id' => $tRow['id'], 'passwd' => $tMd5str, 'private_key' => $tKey, 'updated' => $tTime);
     if ($tUMO->update($tData)) {
         Tool_Fnc::ajaxMsg('密码修改成功', 1);
     }
     Tool_Fnc::ajaxMsg('密码修改失败');
 }
Example #6
0
 public function is_dryweight($pUid, $pDate)
 {
     $tTime = time();
     $tDatetime = strtotime($pDate);
     if ($tTime < $tDatetime) {
         return false;
     }
     $tDWLMO = new DryweightlogModel();
     $tRow = $tDWLMO->field('weight')->where('uid = ' . $pUid . ' and date = \'' . $pDate . '\'')->fRow();
     if (isset($tRow['weight'])) {
         return $tRow['weight'];
     }
     #判断该日期之前的干体重
     $tDWLRow = $tDWLMO->field('weight')->where('uid = ' . $pUid . ' and date < ' . $pDate)->order('date desc')->limit('1')->fRow();
     if (count($tDWLRow)) {
         self::add_weight($pUid, $pDate, $tDWLRow['weight']);
         return $tDWLRow['weight'];
     }
     #判断该日期之后临近的干体重
     $tDWLRow = $tDWLMO->field('weight')->where('uid = ' . $pUid . ' and date > ' . $pDate)->order('date desc')->limit('1')->fRow();
     if (count($tDWLRow)) {
         self::add_weight($pUid, $pDate, $tDWLRow['weight']);
         return $tDWLRow['weight'];
     }
     #用户干体重
     $tUMO = new UserModel();
     $tURow = $tUMO->field('dry_weight weight')->where('id = ' . $pUid)->fRow();
     if (count($tURow)) {
         self::add_weight($pUid, $pDate, $tURow['weight']);
         return $tURow['weight'];
     }
 }
Example #7
0
 public function indexAction()
 {
     $p = $_REQUEST;
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pPassword = empty($p['ptxt']) ? '' : trim($p['ptxt']);
     $pDid = empty($p['did']) ? '' : trim($p['did']);
     $tTime = time();
     if (empty($pPhone)) {
         Tool_Fnc::ajaxMsg('请输入手机号码');
     }
     if (empty($pPassword)) {
         Tool_Fnc::ajaxMsg('请输入密码');
     }
     if (!Tool_Validate::mo($pPhone)) {
         Tool_Fnc::ajaxMsg('手机号不正确');
     }
     if (!Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did 错误');
     }
     $tUserMO = new UserModel();
     $tUserRow = $tUserMO->field('private_key')->where('phone = \'' . $pPhone . '\'')->fRow();
     $tUkey = empty($tUserRow['private_key']) ? '' : $tUserRow['private_key'];
     $tMd5str = Tool_Fnc::markmd5($pPassword, $tUkey);
     $tUserRow = $tUserMO->field('id,user_type')->where('phone = \'' . $pPhone . '\' and passwd = \'' . $tMd5str . '\'')->fRow();
     if (empty($tUserRow['id'])) {
         Tool_Fnc::ajaxMsg("用户名或者密码错误");
     }
     //添加登陆 记录
     $tData = array('uid' => $tUserRow['id'], 'did' => $pDid, 'created' => $tTime, 'ip' => Tool_Fnc::realip());
     $tUllMO = new UserloginlogModel();
     if (!$tUllMO->insert($tData)) {
         Tool_Fnc::ajaxMsg("登录失败");
     }
     //did入库
     $tUDMO = new UserdidModel();
     $tUDRow = $tUDMO->field('count(0) c')->where('uid = ' . $tUserRow['id'] . ' and did = \'' . $pDid . '\'')->fRow();
     if (empty($tUDRow['c'])) {
         $tData = array('uid' => $tUserRow['id'], 'did' => $pDid, 'created' => $tTime, 'ip' => Tool_Fnc::realip());
         $tUDMO->insert($tData);
     }
     $tTokenarr = $this->creattoken($tUserRow['id']);
     //匿名转实名
     $tUserMO->incognito_real($pDid, $tUserRow['id']);
     Tool_Fnc::ajaxMsg("登录成功", 1, array_merge($tTokenarr, array('user_type' => $tUserRow['user_type'])));
     //登录成功返回token
 }
Example #8
0
 /**
  * 获取用户真实手机
  * GET /user/1/phone
  * @method GET_infoAction
  * @param  integer        $id [description]
  * @author NewFuture
  */
 public function GET_phoneAction($id = 0)
 {
     $pid = $this->authPrinter();
     if (TaskModel::where('use_id', $id)->where('pri_id', $pid)->get('id')) {
         $user = UserModel::field('number,phone')->find($id);
         $phone = $user ? Encrypt::decryptPhone($user['phone'], $user['number'], $id) : null;
         $this->response(1, $phone);
     } else {
         $this->response(0, '此同学未在此打印过');
     }
 }
Example #9
0
 public function infoAction()
 {
     $p = $_REQUEST;
     $pUid = empty($p['id']) ? Tool_Fnc::ajaxMsg("异常错误 001") : intval($p['id']);
     $tUMO = new UserModel();
     $tURow = $tUMO->field('headimg,nickname,phone,sex,dry_weight,date_of_birth,medical_addr')->where('id = ' . $pUid)->fRow();
     $tUAMO = new UserassessmentModel();
     $tUARow = $tUAMO->field('*')->where(' uid = ' . $pUid)->fRow();
     $this->assign('tURow', $tURow);
     $this->assign('tUARow', $tUARow);
 }
Example #10
0
 public function indexAction()
 {
     $tWeek = date('w', time());
     $tODTMO = new OrdinarydialysistimeModel();
     $tODTRow = $tODTMO->field('week,time,time_code')->where('uid = ' . $this->tUid)->fRow();
     $tODTRow['week'] = empty($tODTRow['week']) ? -1 : $tODTRow['week'];
     $tODTRow['time'] = empty($tODTRow['time']) ? '' : $tODTRow['time'];
     $tODTRow['time_code'] = empty($tODTRow['time_code']) ? '' : $tODTRow['time_code'];
     $tArr = explode('|', $tODTRow['week']);
     foreach ($tArr as $k => &$v) {
         if ($v == "" || $v == null) {
             unset($tArr[$k]);
         }
     }
     $tUMO = new UserModel();
     $tURow = $tUMO->field('center_id')->where(' id = ' . $this->tUid . ' and user_type = 0')->fRow();
     $tCMO = new CenterModel();
     $tCRow = $tCMO->field('name,today_weather')->where('id =' . $tURow['center_id'])->fRow();
     $tCRow['name'] = empty($tCRow['name']) ? '' : $tCRow['name'];
     $tCRow['today_weather'] = empty($tCRow['today_weather']) ? '' : $tCRow['today_weather'];
     $tArray = array();
     $tArray['time'] = $tODTRow['time'];
     $tArray['time_code'] = $tODTRow['time_code'];
     $tArray['medical_addr'] = $tCRow['name'];
     $tArray['today_weather'] = $tCRow['today_weather'];
     if (in_array($tWeek, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', time())), $tArray));
     }
     if (in_array(($tWeek + 1) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+1day'))), $tArray));
     }
     if (in_array(($tWeek + 2) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+2day'))), $tArray));
     }
     if (in_array(($tWeek + 3) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+3day'))), $tArray));
     }
     if (in_array(($tWeek + 4) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+4day'))), $tArray));
     }
     if (in_array(($tWeek + 5) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+5day'))), $tArray));
     }
     if (in_array(($tWeek + 6) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+6day'))), $tArray));
     }
     Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => ''), $tArray));
 }
Example #11
0
 public function indexAction()
 {
     $tUMO = new UserModel();
     $tDWLMO = new DryweightlogModel();
     $tUDatas = $tUMO->field('id,dry_weight')->fList();
     $tTime = time();
     $tDate = date('Y-m-d', $tTime);
     foreach ($tUDatas as $tURow) {
         $tDWLRow = $tDWLMO->field('id')->where('uid = ' . $tURow['id'] . ' and date = \'' . $tDate . '\'')->fRow();
         if (!empty($tDWLRow['id'])) {
             continue;
         }
         $tData = array('weight' => $tURow['dry_weight'], 'uid' => $tURow['id'], 'created' => $tTime, 'date' => $tDate, 'year' => date('Y', $tTime), 'month' => date('Y-m', $tTime));
         $tDWLMO->insert($tData);
     }
     exit;
 }
Example #12
0
 public function dietAction()
 {
     $p = $_REQUEST;
     $pDate = empty($p['date']) ? Tool_Fnc::ajaxMsg('日期不能为空') : trim($p['date']);
     if (!Tool_Validate::is_date($pDate)) {
         Tool_Fnc::ajaxMsg('日期不正确');
     }
     $tFAMO = new R_FoodaddModel();
     $tFMO = new FoodModel();
     $tSql = 'select * from (select fid,unit,amount,weight from ' . $tFAMO->table . ' where uid = ' . $this->tUid . ' and created >=' . strtotime($pDate) . ' and created <=' . strtotime($pDate . ' 23:59:59') . ') fa, ' . $tFMO->table . ' f where fa.fid = f.id';
     $tList = $tFMO->query($tSql);
     #        if(!count($tList)){Tool_Fnc::ajaxMsg('',1);}
     $tDatas = array();
     $tDatasother = array();
     #已经摄取
     isset($tDatasother['calcium']['number']) ? '' : ($tDatasother['calcium']['number'] = 0);
     isset($tDatasother['vitamin_a']['number']) ? '' : ($tDatasother['vitamin_a']['number'] = 0);
     isset($tDatasother['zinc']['number']) ? '' : ($tDatasother['zinc']['number'] = 0);
     isset($tDatasother['magnesium']['number']) ? '' : ($tDatasother['magnesium']['number'] = 0);
     isset($tDatasother['vitamin_c']['number']) ? '' : ($tDatasother['vitamin_c']['number'] = 0);
     isset($tDatasother['fiber_dietary']['number']) ? '' : ($tDatasother['fiber_dietary']['number'] = 0);
     isset($tDatasother['selenium']['number']) ? '' : ($tDatasother['selenium']['number'] = 0);
     isset($tDatasother['copper']['number']) ? '' : ($tDatasother['copper']['number'] = 0);
     isset($tDatasother['fat']['number']) ? '' : ($tDatasother['fat']['number'] = 0);
     isset($tDatasother['niacin']['number']) ? '' : ($tDatasother['niacin']['number'] = 0);
     isset($tDatasother['vitamin_e']['number']) ? '' : ($tDatasother['vitamin_e']['number'] = 0);
     isset($tDatasother['manganese']['number']) ? '' : ($tDatasother['manganese']['number'] = 0);
     isset($tDatasother['cholesterol']['number']) ? '' : ($tDatasother['cholesterol']['number'] = 0);
     isset($tDatasother['iron']['number']) ? '' : ($tDatasother['iron']['number'] = 0);
     isset($tDatasother['thiamine']['number']) ? '' : ($tDatasother['thiamine']['number'] = 0);
     isset($tDatasother['lactoflavin']['number']) ? '' : ($tDatasother['lactoflavin']['number'] = 0);
     isset($tDatasother['calory']['number']) ? '' : ($tDatasother['calory']['number'] = 0);
     isset($tDatasother['carotene']['number']) ? '' : ($tDatasother['carotene']['number'] = 0);
     isset($tDatas['carbohydrate']['number']) ? '' : ($tDatas['carbohydrate']['number'] = 0);
     isset($tDatas['phosphor']['number']) ? '' : ($tDatas['phosphor']['number'] = 0);
     isset($tDatas['kalium']['number']) ? '' : ($tDatas['kalium']['number'] = 0);
     isset($tDatas['natrium']['number']) ? '' : ($tDatas['natrium']['number'] = 0);
     isset($tDatas['protein']['number']) ? '' : ($tDatas['protein']['number'] = 0);
     foreach ($tList as $tRow) {
         $tDatasother['calcium']['number'] += round($tRow['calcium'] / 100 * $tRow['weight'], 2);
         $tDatasother['vitamin_a']['number'] += round($tRow['vitamin_a'] / 100 * $tRow['weight'], 2);
         $tDatasother['zinc']['number'] += round($tRow['zinc'] / 100 * $tRow['weight'], 2);
         $tDatasother['magnesium']['number'] += round($tRow['magnesium'] / 100 * $tRow['weight'], 2);
         $tDatasother['vitamin_c']['number'] += round($tRow['vitamin_c'] / 100 * $tRow['weight'], 2);
         $tDatasother['fiber_dietary']['number'] += round($tRow['fiber_dietary'] / 100 * $tRow['weight'], 2);
         $tDatasother['selenium']['number'] += round($tRow['selenium'] / 100 * $tRow['weight'], 2);
         $tDatasother['copper']['number'] += round($tRow['copper'] / 100 * $tRow['weight'], 2);
         $tDatasother['fat']['number'] += round($tRow['fat'] / 100 * $tRow['weight'], 2);
         $tDatasother['niacin']['number'] += round($tRow['niacin'] / 100 * $tRow['weight'], 2);
         $tDatasother['vitamin_e']['number'] += round($tRow['vitamin_e'] / 100 * $tRow['weight'], 2);
         $tDatasother['manganese']['number'] += round($tRow['manganese'] / 100 * $tRow['weight'], 2);
         $tDatasother['cholesterol']['number'] += round($tRow['cholesterol'] / 100 * $tRow['weight'], 2);
         $tDatasother['iron']['number'] += round($tRow['iron'] / 100 * $tRow['weight'], 2);
         $tDatasother['thiamine']['number'] += round($tRow['thiamine'] / 100 * $tRow['weight'], 2);
         $tDatasother['lactoflavin']['number'] += round($tRow['lactoflavin'] / 100 * $tRow['weight'], 2);
         $tDatasother['calory']['number'] += round($tRow['calory'] / 100 * $tRow['weight'], 2);
         $tDatasother['carotene']['number'] += round($tRow['carotene'] / 100 * $tRow['weight'], 2);
         $tDatas['carbohydrate']['number'] += round($tRow['carbohydrate'] / 100 * $tRow['weight'], 2);
         #碳水化合物
         $tDatas['phosphor']['number'] += round($tRow['phosphor'] / 100 * $tRow['weight'] / 1000, 2);
         #磷
         #$tDatas['kalium']['number'] += round(($tRow['kalium']/100)*$tRow['weight']/1000,2);#钾
         $tDatas['natrium']['number'] += round($tRow['natrium'] / 100 * $tRow['weight'] / 1000, 2);
         #钠
         $tDatas['protein']['number'] += round($tRow['protein'] / 100 * $tRow['weight'], 2);
         #蛋白质
     }
     unset($tList);
     #干体重
     $tDWLMO = new DryweightlogModel();
     $tDWLRow = $tDWLMO->field('weight')->where('uid = ' . $this->tUid . ' and date = \'' . $pDate . '\'')->fRow();
     if (!count($tDWLRow)) {
         Tool_Fnc::ajaxMsg('', 1);
     }
     #应摄取
     #蛋白质
     $tArr = $tFMO->diet('protein', $tDWLRow['weight']);
     $tDatas['protein']['total'] = implode('-', $tArr);
     $tSurplus = $tArr['end'] - $tDatas['protein']['number'];
     $tDatas['protein']['surplus'] = $tSurplus <= 0 ? 0 : $tSurplus;
     #碳水化合物
     $tArr = $tFMO->diet('carbohydrate', $tDWLRow['weight']);
     $tDatas['carbohydrate']['total'] = implode('-', $tArr);
     $tSurplus = $tArr['end'] - $tDatas['carbohydrate']['number'];
     $tDatas['carbohydrate']['surplus'] = $tSurplus <= 0 ? 0 : $tSurplus;
     #钠
     $tArr = $tFMO->diet('natrium');
     $tDatas['natrium']['total'] = implode('-', $tArr);
     $tSurplus = $tArr['end'] - $tDatas['natrium']['number'];
     $tDatas['natrium']['surplus'] = $tSurplus <= 0 ? 0 : $tSurplus;
     #磷
     $tArr = $tFMO->diet('phosphor');
     $tDatas['phosphor']['total'] = implode('-', $tArr);
     $tSurplus = $tArr['end'] - $tDatas['phosphor']['number'];
     $tDatas['phosphor']['surplus'] = $tSurplus <= 0 ? 0 : $tSurplus;
     #营养摄入评判
     #蛋白质
     $tDatas['protein']['status'] = $tFMO->diet_status('protein', $tDatas['protein']['number'], $tDWLRow['weight']);
     #碳水化合物
     $tDatas['carbohydrate']['status'] = $tFMO->diet_status('carbohydrate', $tDatas['carbohydrate']['number'], $tDWLRow['weight']);
     #钠
     $tDatas['natrium']['status'] = $tFMO->diet_status('natrium', $tDatas['natrium']['number']);
     #磷
     $tDatas['phosphor']['status'] = $tFMO->diet_status('phosphor', $tDatas['phosphor']['number']);
     #控钾单独处理
     $tUMO = new UserModel();
     $tODDMO = new OrdinarydialysisdateModel();
     $tBSDMO = new BqeschedulingdetailModel();
     $tURow = $tUMO->field('user_type')->where('id = ' . $this->tUid)->fRow();
     $tStart = $pDate;
     $tEnd = $pDate;
     if ($tURow['user_type'] == 0) {
         #非白求恩
         $tODDRow = $tODDMO->field('date')->where('uid = \'' . $this->tUid . '\' and date < \'' . $pDate . '\'')->order('date desc')->limit('1')->fRow();
         if (!empty($tODDRow['date'])) {
             $tStart = date('Y-m-d', strtotime($tODDRow['date']) + 86400);
         }
     } else {
         #白求恩
         $tBSDRow = $tBSDMO->field('scheduling_date')->where('uid = \'' . $this->tUid . '\' and scheduling_date < \'' . $pDate . '\'')->order('scheduling_date desc')->limit('1')->fRow();
         if (!empty($tBSDRow['scheduling_date'])) {
             $tStart = date('Y-m-d', strtotime($tBSDRow['scheduling_date']) + 86400);
         }
     }
     $tSql = 'select fid,unit,amount,weight,kalium from (select fid,unit,amount,weight from ' . $tFAMO->table . ' where uid = ' . $this->tUid . ' and created >=' . strtotime($tStart) . ' and created <=' . strtotime($tEnd . ' 23:59:59') . ') fa, ' . $tFMO->table . ' f where fa.fid = f.id';
     $tList = $tFMO->query($tSql);
     foreach ($tList as $tRow) {
         $tDatas['kalium']['number'] += round($tRow['kalium'] / 100 * $tRow['weight'] / 1000, 2);
         #钾
     }
     #钾
     $tArr = $tFMO->diet('kalium');
     #$tDatas['kalium']['total'] = implode('-',$tArr);
     $tDatas['kalium']['total'] = 10;
     $tSurplus = $tArr['end'] - $tDatas['kalium']['number'];
     $tDatas['kalium']['surplus'] = $tSurplus <= 0 ? 0 : $tSurplus;
     $tDatas['kalium']['status'] = $tFMO->diet_status('kalium', $tDatas['kalium']['number']);
     Tool_Fnc::ajaxMsg('', 1, array('main' => $tDatas, 'other' => $tDatasother));
     exit;
 }
Example #13
0
 public function infoAction()
 {
     $tMO = new UserModel();
     $tRow = $tMO->field('headimg,phone,sex,dry_weight,date_of_birth')->where('id = ' . $this->tUid)->fRow();
     if (!count($tRow)) {
         Tool_Fnc::ajaxMsg('获取信息失败');
     }
     $tUAMO = new UserassessmentModel();
     $tARow = $tUAMO->field('name,medical_id')->where(' uid = ' . $this->tUid)->fRow();
     $tCMO = new CenterModel();
     $tCRow = $tCMO->field('name')->where(' id = ' . $tARow['medical_id'])->fRow();
     $tODTMO = new OrdinarydialysistimeModel();
     $tODTRow = $tODTMO->field('time,week,time_code')->where(' uid = ' . $this->tUid)->fRow();
     unset($tARow['medical_id']);
     $tRow = array_merge($tRow, $tARow);
     if (!empty($tRow['headimg']) && !Tool_Validate::url($tRow['headimg'])) {
         $tRow['headimg'] = Yaf_Registry::get("config")->web->url->img . $tRow['headimg'];
     }
     Tool_Fnc::ajaxMsg('', 1, array_merge($tRow, array('medical_addr' => $tCRow['name'], 'assess_time' => $tODTRow)));
 }
Example #14
0
 public function indexAction()
 {
     $tTime = time();
     $tH = date('H', $tTime);
     $tRedis = Cache_Redis::instance();
     $tMO = new OrdinarydialysistimeModel();
     $tODDMO = new OrdinarydialysisdateModel();
     $tUMO = new UserModel();
     $tUDMO = new UserdidModel();
     $tUAMO = new UserassessmentModel();
     $tCMO = new CenterModel();
     if ($tH >= 7 && $tH <= 11) {
         #今日提醒
         $tWeek = date('w', $tTime);
         $tDate = date('Y-m-d', $tTime);
         $tWhere = ' time_code in (2,3)';
         $tDatas = $tMO->field('uid,time_code,time')->where($tWhere . ' and week like \'%' . $tWeek . '%\'')->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('today_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTimecodestr = $tRow['time_code'] == 2 ? '下午' : '晚上';
             $tTimecodestr .= $tRow['time'];
             $tTpl_val = '#timecodestr#=今日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['today_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx')));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime) . $tTimecodestr;
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['today_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
             $tODDRow = $tODDMO->field('count(0) c')->where('uid = ' . $tRow['uid'] . ' and date = \'' . $tDate . '\'')->fRow();
             if (!empty($tODDRow['c'])) {
                 continue;
             }
             #添加透析日期
             $tData = array('date' => $tDate, 'uid' => $tRow['uid'], 'time_code' => $tRow['time_code'], 'created' => $tTime);
             $tODDMO->insert($tData);
         }
     } elseif ($tH >= 13 && $tH <= 21) {
         #第二天上午
         $tWeek = date('w', $tTime + 86400);
         $tDate = date('Y-m-d', $tTime + 86400);
         $tWhere = ' time_code = 1';
         $tDatas = $tMO->field('uid,time_code,time')->where($tWhere . ' and week like \'%' . $tWeek . '%\'')->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('tomorrow_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTimecodestr = '上午' . $tRow['time'];
             $tTpl_val = '#timecodestr#=明日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['tomorrow_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx')));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime + 86400) . '上午' . $tRow['time'];
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['tomorrow_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
             #添加透析日期
             $tODDRow = $tODDMO->field('count(0) c')->where('uid = ' . $tRow['uid'] . ' and date = \'' . $tDate . '\'')->fRow();
             if (!empty($tODDRow['c'])) {
                 continue;
             }
             $tData = array('date' => $tDate, 'uid' => $tRow['uid'], 'time_code' => $tRow['time_code'], 'created' => $tTime);
             $tODDMO->insert($tData);
         }
     }
     exit;
 }
 public function indexAction()
 {
     $tTime = time();
     $tH = date('H', $tTime);
     $tMO = new BqeschedulingdetailModel();
     $tUMO = new UserModel();
     $tUDMO = new UserdidModel();
     $tUAMO = new UserassessmentModel();
     $tCMO = new CenterModel();
     $tRedis = Cache_Redis::instance();
     echo '<pre>';
     if ($tH >= 7 && $tH <= 11) {
         #今日提醒
         $tDatas = $tMO->field('uid,time_code')->where('scheduling_date = \'' . date('Y-m-d', $tTime) . '\' and time_code in(2,3) and uid <> 0')->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('today_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTitle = '透析提醒';
             $tTimecodestr = $tRow['time_code'] == 2 ? '下午' : '晚上';
             $tTpl_val = '#timecodestr#=今日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['today_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx')));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime) . $tTimecodestr;
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['today_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
         }
     } elseif ($tH >= 19 && $tH <= 21) {
         $tTimeCode = 1;
         #第二天上午
         $tDatas = $tMO->field('uid')->where('scheduling_date = \'' . date('Y-m-d', $tTime + 86400) . '\' and time_code = ' . $tTimeCode)->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('tomorrow_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTimecodestr = '上午';
             $tTpl_val = '#timecodestr#=明日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=明日天气' . $tCRow['tomorrow_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'])));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime + 86400) . '上午' . $tRow['time'];
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['tomorrow_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
         }
     }
 }
Example #16
0
 public function indexAction()
 {
     $p = $_REQUEST;
     //判断用户是否为白求恩用户
     $tUMO = new UserModel();
     $tURow = $tUMO->field('user_type')->where(' id = ' . $this->tUid)->fRow();
     if (empty($tURow) || $tURow['user_type'] == 1) {
         Tool_Fnc::ajaxMsg('操作错误');
     }
     $tData = array();
     $pPatientId = !isset($p['patient_id']) ? '' : ($tData['patient_id'] = Tool_Fnc::safe_string($p['patient_id']));
     $pInpNo = !isset($p['inp_no']) ? '' : ($tData['inp_no'] = Tool_Fnc::safe_string($p['inp_no']));
     $pMedicalDate01 = !isset($p['medical_date_01']) ? '' : ($tData['medical_date_01'] = Tool_Fnc::safe_string($p['medical_date_01'] . '-01'));
     $pMedicalDate02 = !isset($p['medical_date_02']) ? '' : ($tData['medical_date_02'] = Tool_Fnc::safe_string($p['medical_date_02'] . '-01'));
     $pMedicalDate03 = !isset($p['medical_date_03']) ? '' : ($tData['medical_date_03'] = Tool_Fnc::safe_string($p['medical_date_03'] . '-01'));
     $pMedicalDate04 = !isset($p['medical_date_04']) ? '' : ($tData['medical_date_04'] = Tool_Fnc::safe_string($p['medical_date_04'] . '-01'));
     $pPresent01 = !isset($p['present_01']) ? '' : ($tData['present_01'] = Tool_Fnc::safe_string($p['present_01']));
     $pPresent02 = !isset($p['present_02']) ? '' : ($tData['present_02'] = Tool_Fnc::safe_string($p['present_02']));
     $pPresent03 = !isset($p['present_03']) ? '' : ($tData['present_03'] = Tool_Fnc::safe_string($p['present_03']));
     $pPresent04 = !isset($p['present_04']) ? '' : ($tData['present_04'] = Tool_Fnc::safe_string($p['present_04']));
     $pPresent05 = !isset($p['present_05']) ? '' : ($tData['present_05'] = Tool_Fnc::safe_string($p['present_05']));
     $pPresent06 = !isset($p['present_06']) ? '' : ($tData['present_06'] = Tool_Fnc::safe_string($p['present_06']));
     $pPresent07 = !isset($p['present_07']) ? '' : ($tData['present_07'] = Tool_Fnc::safe_string($p['present_07']));
     $pPresent08 = !isset($p['present_08']) ? '' : ($tData['present_08'] = Tool_Fnc::safe_string($p['present_08']));
     $pPresent09 = !isset($p['present_09']) ? '' : ($tData['present_09'] = Tool_Fnc::safe_string($p['present_09']));
     $pPresent10 = !isset($p['present_10']) ? '' : ($tData['present_10'] = Tool_Fnc::safe_string($p['present_10']));
     $pPresent11 = !isset($p['present_11']) ? '' : ($tData['present_11'] = Tool_Fnc::safe_string($p['present_11']));
     $pPresent12 = !isset($p['present_12']) ? '' : ($tData['present_12'] = Tool_Fnc::safe_string($p['present_12']));
     $pPresent13 = !isset($p['present_13']) ? '' : ($tData['present_13'] = Tool_Fnc::safe_string($p['present_13']));
     $pPresent14 = !isset($p['present_14']) ? '' : ($tData['present_14'] = Tool_Fnc::safe_string($p['present_14']));
     $pPresent15 = !isset($p['present_15']) ? '' : ($tData['present_15'] = Tool_Fnc::safe_string($p['present_15']));
     $pPresent16 = !isset($p['present_16']) ? '' : ($tData['present_16'] = Tool_Fnc::safe_string($p['present_16']));
     $pPresent17 = !isset($p['present_17']) ? '' : ($tData['present_17'] = Tool_Fnc::safe_string($p['present_17']));
     $pPresent18 = !isset($p['present_18']) ? '' : ($tData['present_18'] = Tool_Fnc::safe_string($p['present_18']));
     $pPresent19 = !isset($p['present_19']) ? '' : ($tData['present_19'] = Tool_Fnc::safe_string($p['present_19']));
     $pPresent20 = !isset($p['present_20']) ? '' : ($tData['present_20'] = Tool_Fnc::safe_string($p['present_20']));
     $pPresent21 = !isset($p['present_21']) ? '' : ($tData['present_21'] = Tool_Fnc::safe_string($p['present_21']));
     $pPresent22 = !isset($p['present_22']) ? '' : ($tData['present_22'] = Tool_Fnc::safe_string($p['present_22']));
     $pPresent23 = !isset($p['present_23']) ? '' : ($tData['present_23'] = Tool_Fnc::safe_string($p['present_23']));
     $pPresent24 = !isset($p['present_24']) ? '' : ($tData['present_24'] = Tool_Fnc::safe_string($p['present_24']));
     $pComplication01 = !isset($p['complication_01']) ? '' : ($tData['complication_01'] = Tool_Fnc::safe_string($p['complication_01']));
     $pComplication02 = !isset($p['complication_02']) ? '' : ($tData['complication_02'] = Tool_Fnc::safe_string($p['complication_02']));
     $pComplication03 = !isset($p['complication_03']) ? '' : ($tData['complication_03'] = Tool_Fnc::safe_string($p['complication_03']));
     $pComplication04 = !isset($p['complication_04']) ? '' : ($tData['complication_04'] = Tool_Fnc::safe_string($p['complication_04']));
     $pComplication05 = !isset($p['complication_05']) ? '' : ($tData['complication_05'] = Tool_Fnc::safe_string($p['complication_05']));
     $pComplication06 = !isset($p['complication_06']) ? '' : ($tData['complication_06'] = Tool_Fnc::safe_string($p['complication_06']));
     $pMedPast011 = !isset($p['med_past_011']) ? '' : ($tData['med_past_011'] = Tool_Fnc::safe_string($p['med_past_011']));
     $pMedPast012 = !isset($p['med_past_012']) ? '' : ($tData['med_past_012'] = Tool_Fnc::safe_string($p['med_past_012']));
     $pMedPast013 = !isset($p['med_past_013']) ? '' : ($tData['med_past_013'] = Tool_Fnc::safe_string($p['med_past_013']));
     $pMedPast021 = !isset($p['med_past_021']) ? '' : ($tData['med_past_021'] = Tool_Fnc::safe_string($p['med_past_021']));
     $pMedPast022 = !isset($p['med_past_022']) ? '' : ($tData['med_past_022'] = Tool_Fnc::safe_string($p['med_past_022']));
     $pMedPast031 = !isset($p['med_past_031']) ? '' : ($tData['med_past_031'] = Tool_Fnc::safe_string($p['med_past_031']));
     $pMedPast032 = !isset($p['med_past_032']) ? '' : ($tData['med_past_032'] = Tool_Fnc::safe_string($p['med_past_032']));
     $pMedPast033 = !isset($p['med_past_033']) ? '' : ($tData['med_past_033'] = Tool_Fnc::safe_string($p['med_past_033']));
     $pMedPast034 = !isset($p['med_past_034']) ? '' : ($tData['med_past_034'] = Tool_Fnc::safe_string($p['med_past_034']));
     $pMedPast035 = !isset($p['med_past_035']) ? '' : ($tData['med_past_035'] = Tool_Fnc::safe_string($p['med_past_035']));
     $pMedPast036 = !isset($p['med_past_036']) ? '' : ($tData['med_past_036'] = Tool_Fnc::safe_string($p['med_past_036']));
     $pMedPast037 = !isset($p['med_past_037']) ? '' : ($tData['med_past_037'] = Tool_Fnc::safe_string($p['med_past_037']));
     $pMedPast041 = !isset($p['med_past_041']) ? '' : ($tData['med_past_041'] = Tool_Fnc::safe_string($p['med_past_041']));
     $pMedPast042 = !isset($p['med_past_042']) ? '' : ($tData['med_past_042'] = Tool_Fnc::safe_string($p['med_past_042']));
     $pMedPast043 = !isset($p['med_past_043']) ? '' : ($tData['med_past_043'] = Tool_Fnc::safe_string($p['med_past_043']));
     $pMedPast044 = !isset($p['med_past_044']) ? '' : ($tData['med_past_044'] = Tool_Fnc::safe_string($p['med_past_044']));
     $pMedPast045 = !isset($p['med_past_045']) ? '' : ($tData['med_past_045'] = Tool_Fnc::safe_string($p['med_past_045']));
     $pMedPast046 = !isset($p['med_past_046']) ? '' : ($tData['med_past_046'] = Tool_Fnc::safe_string($p['med_past_046']));
     $pMedPast05 = !isset($p['med_past_05']) ? '' : ($tData['med_past_05'] = Tool_Fnc::safe_string($p['med_past_05']));
     $pMedPast06 = !isset($p['med_past_06']) ? '' : ($tData['med_past_06'] = Tool_Fnc::safe_string($p['med_past_06']));
     $pMedPast07 = !isset($p['med_past_07']) ? '' : ($tData['med_past_07'] = Tool_Fnc::safe_string($p['med_past_07']));
     $pMedPast08 = !isset($p['med_past_08']) ? '' : ($tData['med_past_08'] = Tool_Fnc::safe_string($p['med_past_08']));
     $pMedPast09 = !isset($p['med_past_09']) ? '' : ($tData['med_past_09'] = Tool_Fnc::safe_string($p['med_past_09']));
     $pMedPast10 = !isset($p['med_past_10']) ? '' : ($tData['med_past_10'] = Tool_Fnc::safe_string($p['med_past_10']));
     $pMedPast11 = !isset($p['med_past_11']) ? '' : ($tData['med_past_11'] = Tool_Fnc::safe_string($p['med_past_11']));
     $pMedPast12 = !isset($p['med_past_12']) ? '' : ($tData['med_past_12'] = Tool_Fnc::safe_string($p['med_past_12']));
     $pMedPast13 = !isset($p['med_past_13']) ? '' : ($tData['med_past_13'] = Tool_Fnc::safe_string($p['med_past_13']));
     $pBodyHeight = !isset($p['body_height']) ? '' : ($tData['body_height'] = floatval($p['body_height']));
     $pDialysisNo = !isset($p['dialysis_no']) ? '' : ($tData['dialysis_no'] = floatval($p['dialysis_no']));
     $pAnticoagulation = !isset($p['anticoagulation']) ? '' : ($tData['anticoagulation'] = Tool_Fnc::safe_string($p['anticoagulation']));
     $pIfIn = !isset($p['if_in']) ? '' : ($tData['if_in'] = Tool_Fnc::safe_string($p['if_in']));
     $pWeeks = !isset($p['weeks']) ? '' : ($tData['weeks'] = floatval($p['weeks']));
     $pPresent101 = !isset($p['present_10_1']) ? '' : ($tData['present_10_1'] = Tool_Fnc::safe_string($p['present_10_1']));
     $pPresent041 = !isset($p['present_04_1']) ? '' : ($tData['present_04_1'] = Tool_Fnc::safe_string($p['present_04_1']));
     $pPresent201 = !isset($p['present_20_1']) ? '' : ($tData['present_20_1'] = Tool_Fnc::safe_string($p['present_20_1']));
     $pPresent241 = !isset($p['present_24_1']) ? '' : ($tData['present_24_1'] = Tool_Fnc::safe_string($p['present_24_1']));
     $pMedPast051 = !isset($p['med_past_05_1']) ? '' : ($tData['med_past_05_1'] = Tool_Fnc::safe_string($p['med_past_05_1']));
     $pMedPast061 = !isset($p['med_past_06_1']) ? '' : ($tData['med_past_06_1'] = Tool_Fnc::safe_string($p['med_past_06_1']));
     $pMedPast071 = !isset($p['med_past_07_1']) ? '' : ($tData['med_past_07_1'] = Tool_Fnc::safe_string($p['med_past_07_1']));
     $pMedPast081 = !isset($p['med_past_08_1']) ? '' : ($tData['med_past_08_1'] = Tool_Fnc::safe_string($p['med_past_08_1']));
     $pMedPast091 = !isset($p['med_past_09_1']) ? '' : ($tData['med_past_09_1'] = Tool_Fnc::safe_string($p['med_past_09_1']));
     $pMedPast101 = !isset($p['med_past_10_1']) ? '' : ($tData['med_past_10_1'] = Tool_Fnc::safe_string($p['med_past_10_1']));
     $pMedPast111 = !isset($p['med_past_11_1']) ? '' : ($tData['med_past_11_1'] = Tool_Fnc::safe_string($p['med_past_11_1']));
     $pMedPast121 = !isset($p['med_past_12_1']) ? '' : ($tData['med_past_12_1'] = Tool_Fnc::safe_string($p['med_past_12_1']));
     $pMedPast131 = !isset($p['med_past_13_1']) ? '' : ($tData['med_past_13_1'] = Tool_Fnc::safe_string($p['med_past_13_1']));
     $pMedPast102 = !isset($p['med_past_10_2']) ? '' : ($tData['med_past_10_2'] = Tool_Fnc::safe_string($p['med_past_10_2']));
     $pMethod = !isset($p['method']) ? '' : ($tData['method'] = intval($p['method']));
     $pMedicalType = !isset($p['medical_type']) ? '' : ($tData['medical_type'] = Tool_Fnc::safe_string($p['medical_type']));
     $pProvinces = !isset($p['provinces']) ? '' : ($tData['provinces'] = Tool_Fnc::safe_string($p['provinces']));
     $pCities = !isset($p['cities']) ? '' : ($tData['cities'] = Tool_Fnc::safe_string($p['cities']));
     $pMedicalAddr = !isset($p['medical_addr']) ? '' : ($tData['medical_addr'] = Tool_Fnc::safe_string($p['medical_addr']));
     $pName = !isset($p['name']) ? '' : ($tData['name'] = Tool_Fnc::safe_string($p['name']));
     $tTime = time();
     $pAssessTime = !isset($p['assess_time']) ? '' : ($tData['assess_time'] = Tool_Fnc::safe_string($p['assess_time']));
     $pAssessWeek = !isset($p['assess_week']) ? '' : ($tData['assess_week'] = Tool_Fnc::safe_string($p['assess_week']));
     $pAssesstimecode = !isset($p['assess_time_code']) ? '' : ($tData['assess_time_code'] = intval($p['assess_time_code']));
     //判断是否有数据
     if (!count($tData)) {
         Tool_Fnc::ajaxMsg('数据异常');
     }
     //更新用户表字段用户名
     if (isset($tData['name']) && !empty($tData['name'])) {
         $tUMO = new UserModel();
         $tUData = array('id' => $this->tUid, 'nickname' => $tData['name'], 'updated' => $tTime);
         if (!$tUMO->update($tUData)) {
             Tool_Fnc::ajaxMsg('更新失败');
         }
     }
     //先更新透析中心
     $tCMO = new CenterModel();
     $tCData = array();
     if (isset($tData['medical_addr']) && !empty($tData['medical_addr'])) {
         $tCData = array_merge($tCData, array('name' => $tData['medical_addr']));
     }
     if (isset($tData['provinces']) && !empty($tData['provinces'])) {
         $tCData = array_merge($tCData, array('provinces' => $tData['provinces']));
     }
     if (isset($tData['cities']) && !empty($tData['cities'])) {
         $tCData = array_merge($tCData, array('cities' => $tData['cities']));
     }
     if (!empty($tCData)) {
         $sql = "select id from {$tCMO->table} where name = '{$tData['medical_addr']}' and provinces = '{$tData['provinces']}' and cities ='{$tData['cities']}' and type = 0";
         $tCMOList = $tCMO->query($sql);
         if (empty($tCMOList[0]['id'])) {
             $tCData = array_merge($tCData, array('created' => $tTime));
             $tCData = array_merge($tCData, array('type' => 0));
             //获取天气
             $tWeatherCities = array('北京', '天津', '上海', '重庆');
             if (in_array($tCData['provinces'], $tWeatherCities)) {
                 $tWeatherCity = $tCData['provinces'];
             } else {
                 $tWeatherCity = $tCData['cities'];
             }
             $tWeather = Tool_Fnc::weather_juhe($tWeatherCity);
             $tCData['today_weather'] = $tWeather['today_weather'];
             $tCData['tomorrow_weather'] = $tWeather['tomorrow_weather'];
             if (!($tMedicalId = $tCMO->insert($tCData))) {
                 Tool_Fnc::ajaxMsg('插入失败');
             }
             $tUData = array('id' => $this->tUid, 'center_id' => $tMedicalId, 'medical_addr' => $tData['medical_addr'], 'updated' => $tTime);
         } else {
             $tUData = array('id' => $this->tUid, 'center_id' => $tCMOList[0]['id'], 'medical_addr' => $tData['medical_addr'], 'updated' => $tTime);
         }
         //更新用户表字段
         $tUMO = new UserModel();
         if (!$tUMO->update($tUData)) {
             Tool_Fnc::ajaxMsg('更新失败');
         }
     }
     //更新普通会员的透析时间
     $tODTMO = new OrdinarydialysistimeModel();
     $tODTData = array();
     if (isset($tData['assess_time'])) {
         $tData['assess_time'] = empty($tData['assess_time']) ? '' : Tool_Fnc::safe_string($tData['assess_time']);
         $tODTData = array_merge($tODTData, array('time' => Tool_Fnc::safe_string($tData['assess_time'])));
     }
     if (isset($tData['assess_week'])) {
         $tData['assess_week'] = empty($tData['assess_week']) ? '' : Tool_Fnc::safe_string($tData['assess_week']);
         $tODTData = array_merge($tODTData, array('week' => Tool_Fnc::safe_string($tData['assess_week'])));
     }
     if (isset($tData['assess_time_code'])) {
         $tData['assess_time_code'] = empty($tData['assess_time_code']) ? 0 : intval($tData['assess_time_code']);
         $tODTData = array_merge($tODTData, array('time_code' => intval($tData['assess_time_code'])));
     }
     if (!empty($tODTData)) {
         $tODTRow = $tODTMO->field('id')->where(' uid = ' . $this->tUid)->fRow();
         if (empty($tODTRow['id'])) {
             $tODTData = array_merge($tODTData, array('created' => $tTime));
             $tODTData = array_merge($tODTData, array('uid' => $this->tUid));
             if (!$tODTMO->insert($tODTData)) {
                 Tool_Fnc::ajaxMsg('插入失败');
             }
         } else {
             $tODTData = array_merge($tODTData, array('updated' => $tTime));
             $tODTData = array_merge($tODTData, array('id' => $tODTRow['id']));
             if (!$tODTMO->update($tODTData)) {
                 Tool_Fnc::ajaxMsg('更新失败');
             }
         }
     }
     //判断是更新还是插入健康档案
     $tUAMO = new UserassessmentModel();
     $tRow = $tUAMO->field('id,medical_id')->where(' uid = ' . $this->tUid)->fRow();
     $tData['uid'] = $this->tUid;
     $tRow['medical_id'] = empty($tRow['medical_id']) ? 0 : $tRow['medical_id'];
     $tData['medical_id'] = isset($tMedicalId) ? $tMedicalId : $tRow['medical_id'];
     if (empty($tRow['id'])) {
         $tData = array_merge($tData, array('created' => $tTime));
         if (!$tUAMO->insert($tData)) {
             Tool_Fnc::ajaxMsg('插入失败');
         }
     } else {
         $tData['id'] = $tRow['id'];
         $tData['updated'] = $tTime;
         if (!$tUAMO->update($tData)) {
             Tool_Fnc::ajaxMsg('更新失败');
         }
     }
     Tool_Fnc::ajaxMsg('数据操作成功', 1);
 }
Example #17
0
 /**
  * 获取用户真实手机
  * GET /user/1/phone
  * @method GET_infoAction
  * @param  integer        $id [description]
  * @author NewFuture
  */
 public function GET_phoneAction($id = 0)
 {
     $id = $this->auth($id);
     $user = UserModel::field('number,phone')->find($id);
     $phone = $user ? Encrypt::decryptPhone($user['phone'], $user['number'], $id) : null;
     $this->response(1, $phone);
 }
Example #18
0
 /**
  * 原密码重置密码
  * @method PUT_indexAction
  * @author NewFuture
  */
 public function PUT_indexAction($id)
 {
     $this->auth($id);
     $response['status'] = 0;
     if (!Input::put('password', $password, 'isMd5')) {
         $response['info'] = '新的密码格式不对';
     } elseif (!Input::put('old', $old_pwd, 'isMd5')) {
         $response['info'] = '请输入原密码';
     } else {
         /*数据库中读取用户数据*/
         $user = UserModel::field('password,number')->find($id);
         $number = $user['number'];
         if (!$user || Encrypt::encryptPwd($old_pwd, $number) != $user['password']) {
             $response['info'] = '原密码错误';
         } elseif ($user->update(['password' => Encrypt::encryptPwd($password, $number)]) >= 0) {
             $response['info'] = '修改成功';
             $response['status'] = 1;
         } else {
             $response['info'] = '修改失败';
         }
     }
     $this->response = $response;
 }
Example #19
0
 public function ckauthcodeAction()
 {
     $p = $_REQUEST;
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pReqmode = empty($p['reqmode']) ? '' : intval(trim($p['reqmode']));
     #1: 注册请求;2: 忘记/找回密码请求;   3:第三方
     $pCode = empty($p['code']) ? '' : intval(trim($p['code']));
     $tTime = time();
     if (!Tool_Validate::mo($pPhone)) {
         Tool_Fnc::ajaxMsg('手机号不正确');
     }
     $tCodeMO = new PhonecodeModel();
     $tCodeCRow = $tCodeMO->check($pPhone, $pReqmode, $pCode);
     $tUMO = new UserModel();
     $tURow = $tUMO->field('count(0) c')->where('phone = \'' . $pPhone . '\'')->fRow();
     $tIsregphone = 0;
     if (!empty($tURow['c'])) {
         $tIsregphone = 1;
     }
     Tool_Fnc::ajaxMsg($tCodeCRow['msg'], $tCodeCRow['status'], array('isregphone' => $tIsregphone));
 }
 public function yearAction()
 {
     $p = $_REQUEST;
     $pDate = empty($p['date']) ? '' : trim($p['date']);
     $pOpt = empty($p['opt']) ? 'left' : Tool_Fnc::safe_string($p['opt']);
     if (!empty($pDate) && !Tool_Validate::is_date($pDate)) {
         Tool_Fnc::ajaxMsg('日期不正确');
     }
     $tWhere = '';
     $tTime = strtotime($pDate);
     if ($pOpt == 'left') {
         if (!empty($pDate)) {
             $tEnd = date('Y-m-d', $tTime - 86400);
         } else {
             $tTime = time();
             $tEnd = date('Y-m-d');
         }
         $tStart = date('Y-m-d', $tTime - 86400 * 364);
     } else {
         if (!empty($pDate)) {
             $tStart = date('Y-m-d', $tTime + 86400);
         } else {
             $tTime = time();
             $tStart = date('Y-m-d');
         }
         $tEnd = date('Y-m-d', $tTime + 86400 * 364);
     }
     $tTRMO = new BqetreatmentrecordModel();
     $tTRDatas = $tTRMO->field('bodyweight_bef,bodyweight_after,treate_date')->where('uid = ' . $this->tUid . ' and treate_date between \'' . $tStart . '\' and \'' . $tEnd . '\'')->order('treate_date asc')->fList();
     $tDWLMO = new DryweightlogModel();
     $tDWLDatas = $tDWLMO->field('weight,date')->where('uid = ' . $this->tUid . ' and date between \'' . $tStart . '\' and \'' . $tEnd . '\'')->fList();
     //最开始日期
     $tSql = 'select treate_date from ' . $tTRMO->table . ' where uid = ' . $this->tUid . ' order by treate_date asc limit 1';
     $tTRMOList = $tTRMO->query($tSql);
     #用户最新干体重
     $tUMO = new UserModel();
     $tURow = $tUMO->field('dry_weight')->where('id = ' . $this->tUid)->fRow();
     //如果没有干体重 初始化
     $tDatearr = array();
     for ($i = 0; $i < 364; $i++) {
         $tDatearr[] = date('Y-m-d', strtotime($tStart) + 86400 * $i);
     }
     $tDWLDate = array();
     foreach ($tDWLDatas as $tRow) {
         $tDWLDate[] = $tRow['date'];
     }
     $tDatediff = array_diff($tDatearr, $tDWLDate);
     $tDiffarr = array();
     foreach ($tDatediff as $tDate) {
         break;
         #判断该日期之前的干体重
         $tDWLRow = $tDWLMO->field('weight')->where('uid = ' . $this->tUid . ' and date < ' . $tDate)->order('date desc')->limit('1')->fRow();
         if (count($tDWLRow)) {
             $tDWLDatas[] = $tDiffarr[] = array('date' => $tDate, 'weight' => $tDWLRow['weight']);
             continue;
         }
         #判断该日期之后临近的干体重
         $tDWLRow = $tDWLMO->field('weight')->where('uid = ' . $this->tUid . ' and date > ' . $tDate)->order('date desc')->limit('1')->fRow();
         if (count($tDWLRow)) {
             $tDWLDatas[] = $tDiffarr[] = array('date' => $tDate, 'weight' => $tDWLRow['weight']);
             continue;
         }
         #当前用户干体重
         $tDWLDatas[] = $tDiffarr[] = array('date' => $tDate, 'weight' => $tURow['dry_weight']);
     }
     #将没有干体重的天入库
     foreach ($tDiffarr as $tRow) {
         break;
         if ($tDWLMO->in_weight($this->tUid, $tRow['date'])) {
             continue;
         }
         $tData = array('weight' => $tRow['weight'], 'uid' => $this->tUid, 'created' => $tTime, 'date' => $tRow['date'], 'month' => date('Y-m', strtotime($tRow['date'])), 'year' => date('Y-m', strtotime($tRow['date'])));
         $tDWLMO->insert($tData);
     }
     #排除 只要有体重的 干体重╮(╯▽╰)╭
     $tTRDate = array();
     foreach ($tTRDatas as $tRow) {
         $tTRDate[] = $tRow['treate_date'];
     }
     foreach ($tDWLDatas as $tKey => $tRow) {
         if (!in_array($tRow['date'], $tTRDate)) {
             unset($tDWLDatas[$tKey]);
         }
     }
     $tDWLDatas = Tool_Fnc::arraySort($tDWLDatas, 'date', 'asc');
     Tool_Fnc::ajaxMsg('', 1, array('dry_weight' => $tDWLDatas, 'weight' => $tTRDatas, 'start_treate_date' => $tTRMOList[0]['treate_date']));
 }
Example #21
0
 public function regAction()
 {
     $p = $_REQUEST;
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pPassword = empty($p['ptxt']) ? '' : trim($p['ptxt']);
     #客户端发送的必须是md5的 密码
     $pCode = empty($p['code']) ? '0' : trim($p['code']);
     $pDid = empty($p['did']) ? '' : trim($p['did']);
     $tTime = time();
     if (empty($pPassword)) {
         Tool_Fnc::ajaxMsg('密码不能为空');
     }
     if (empty($pCode)) {
         Tool_Fnc::ajaxMsg('验证码不能为空');
     }
     if (!Tool_Validate::integer($pCode)) {
         Tool_Fnc::ajaxMsg('验证码格式错误');
     }
     if (strlen($pPassword) != 32) {
         Tool_Fnc::ajaxMsg('接口发送的必须是密文密码');
     }
     if (empty($pDid) || !Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did error');
     }
     $tUMO = new UserModel();
     $tRow = $tUMO->field('count(0) c')->where('phone = \'' . $pPhone . '\'')->fRow();
     if (!empty($tRow['c'])) {
         Tool_Fnc::ajaxMsg('该手机已被他人使用,请重新输入');
     }
     $tUMO = new UserModel();
     $tKey = Tool_Fnc::newrand(4);
     $tMd5str = Tool_Fnc::markmd5($pPassword, $tKey);
     $tCodeMO = new PhonecodeModel();
     $tCodeCRow = $tCodeMO->check($pPhone, 1, $pCode);
     if ($tCodeCRow['status'] == 0) {
         Tool_Fnc::ajaxMsg($tCodeCRow['msg']);
     }
     $pSex = !isset($p['sex']) ? Tool_Fnc::ajaxMsg('请填写性别') : intval($p['sex']);
     $pDryWeight = !isset($p['dry_weight']) ? Tool_Fnc::ajaxMsg('请填写干体重') : floatval($p['dry_weight']);
     $pDateOfBirth = empty($p['date_of_birth']) ? Tool_Fnc::ajaxMsg('请填写出生日期') : trim($p['date_of_birth']);
     if (!empty($pDateOfBirth) && !Tool_Validate::is_date($pDateOfBirth)) {
         Tool_Fnc::ajaxMsg('日期格式不正确');
     }
     $tData = array('phone' => $pPhone, 'reg_ip' => Tool_Fnc::realip(), "passwd" => $tMd5str, "reg_time" => $tTime, 'private_key' => $tKey, 'reg_did' => $pDid, 'user_type' => 0, 'sex' => $pSex, 'dry_weight' => $pDryWeight, 'date_of_birth' => $pDateOfBirth, 'reg_did' => $pDid);
     if (!($tID = $tUMO->insert($tData))) {
         Tool_Fnc::ajaxMsg('注册失败');
     }
     //did入库
     $tUDMO = new UserdidModel();
     $tUDRow = $tUDMO->field('count(0) c')->where('uid = ' . $tID . ' and did = \'' . $pDid . '\'')->fRow();
     if (empty($tUDRow['c'])) {
         $tData = array('uid' => $tID, 'did' => $pDid, 'created' => $tTime, 'ip' => Tool_Fnc::realip());
         $tUDMO->insert($tData);
     }
     $tTokenarr = $this->creattoken($tID);
     //干重记录表数据更新
     $tDWMO = new DryweightlogModel();
     $tDryWeightLog = array('uid' => $tID, 'weight' => $pDryWeight, 'date' => date('Y-m-d'), 'month' => date('Y-m'), 'year' => date('Y'), 'created' => $tTime);
     $tDWMO->insert($tDryWeightLog);
     //匿名转实名
     $tUMO->incognito_real($pDid, $tID);
     $tTokenarr = array_merge($tTokenarr, array('user_type' => 0));
     Tool_Fnc::ajaxMsg('注册成功', 1, $tTokenarr);
 }