Esempio n. 1
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'];
     }
 }
Esempio n. 2
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);
 }
Esempio n. 3
0
 public function indexAction()
 {
     echo '<pre>';
     $tTime = time();
     $tH = date('H', $tTime);
     $tWhere = ' and PUNCTURE_NURSE is not NULL';
     if ($tH >= 22 && $tH <= 23) {
         $tWhere = '';
     }
     $tTRMO = new BqetreatmentrecordModel();
     $tUAMO = new UserassessmentModel();
     $tDWLMO = new DryweightlogModel();
     $tUMO = new UserModel();
     $tOci = new Orm_Oci();
     $tHSql = 'select patient_id,treatment_times,fluid_volume,dialyzer,dialysis_mach,volume_na,volume_ca,volume_hc,volume_quantity,vascular_access,body_weight,bodyweight_bef,bodyweight_increase,ultrafilt_quantity,ufr,treat_time,blood_quantity,first_agent,maitain,additional,total_quantity,t,p,r,bp1,bp2,actual_treat_time,bodyweight_after,actual_ultrafilt_quantity,t_after,p_after,bp1_after,bp2_after,treate_summary,puncture_nurse,treate_nurse,doctor_user,to_char(treate_date,\'YYYY-mm-dd\') treate_date,treate_mode,dfz,vein_puncture,artery_puncture,kidney_solidification,dialyze_allergy,takeoff_needle from  treatment_record where to_char(TREATE_DATE,\'YYYY-mm-dd\')  = \'' . date('Y-m-d', $tTime) . '\' ' . $tWhere;
     #$tHSql = 'select patient_id,treatment_times,fluid_volume,dialyzer,dialysis_mach,volume_na,volume_ca,volume_hc,volume_quantity,vascular_access,body_weight,bodyweight_bef,bodyweight_increase,ultrafilt_quantity,ufr,treat_time,blood_quantity,first_agent,maitain,additional,total_quantity,t,p,r,bp1,bp2,actual_treat_time,bodyweight_after,actual_ultrafilt_quantity,t_after,p_after,bp1_after,bp2_after,treate_summary,puncture_nurse,treate_nurse,doctor_user,to_char(treate_date,\'YYYY-mm-dd\') treate_date,treate_mode,dfz,vein_puncture,artery_puncture,kidney_solidification,dialyze_allergy,takeoff_needle from  treatment_record where to_char(TREATE_DATE,\'YYYY-mm-dd\')  between \'2015-10-08\' and \'2015-12-08\'';
     $tDatas = $tOci->getAll($tHSql);
     foreach ($tDatas as $tRow) {
         $tTRRow = $tTRMO->field('count(0) c')->where('patient_id = \'' . $tRow['PATIENT_ID'] . '\' and treate_date = \'' . $tRow['TREATE_DATE'] . '\'')->fRow();
         if (!empty($tTRRow['c'])) {
             continue;
         }
         foreach ($tRow as $k => $v) {
             $k = strtolower($k);
             $tData[$k] = $v;
         }
         $tUARow = $tUAMO->field('uid')->where('patient_id = \'' . $tRow['PATIENT_ID'] . '\'')->fRow();
         $tData['uid'] = empty($tUARow['uid']) ? 0 : $tUARow['uid'];
         echo $tTRMO->insert($tData);
         echo "\r\n";
         if (empty($tRow['BODY_WEIGHT'])) {
             continue;
         }
         if (!empty($tUid) && date('Y-m-d', $tTime) == $tRow['TREATE_DATE']) {
             #用户存在 并且干体重记录日期是今日 的话更新用户信息表
             $tData = array('id' => $tUid, 'dry_weight' => $tRow['BODY_WEIGHT']);
             $tUMO->update($tData);
         }
         $tDWLRow = $tDWLMO->field('id')->where('patient_id = \'' . $tRow['PATIENT_ID'] . '\' and date = \'' . $tRow['TREATE_DATE'] . '\'')->fRow();
         if (!empty($tDWLRow['id'])) {
             $tData = array('id' => $tDWLRow['id'], 'weight' => $tRow['BODY_WEIGHT'], 'updated' => $tTime);
             $tDWLMO->update($tData);
         } else {
             #干体重log
             $tData = array('weight' => $tRow['BODY_WEIGHT'], 'created' => $tTime, 'date' => $tRow['TREATE_DATE'], 'month' => date('Y-m', strtotime($tRow['TREATE_DATE'])), 'year' => date('Y', strtotime($tRow['TREATE_DATE'])), 'patient_id' => $tRow['PATIENT_ID']);
             $tDWLMO->insert($tData);
         }
     }
     exit;
 }
Esempio n. 4
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;
 }
Esempio n. 5
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;
 }
Esempio n. 6
0
 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']));
 }
Esempio n. 7
0
 public function editAction()
 {
     $p = $_REQUEST;
     $tUMO = new UserModel();
     $tURow = $tUMO->field('user_type')->where(' id = ' . $this->tUid)->fRow();
     if ($tURow['user_type'] == 1) {
         Tool_Fnc::ajaxMsg('操作异常');
     }
     $tData = array();
     if (isset($p['name'])) {
         $tData = array_merge($tData, array('nickname' => Tool_Fnc::safe_string($p['name'])));
     }
     if (isset($p['date_of_birth'])) {
         $tData = array_merge($tData, array('date_of_birth' => date('Y-m-d', strtotime($p['date_of_birth']))));
     }
     if (isset($p['sex'])) {
         $tData = array_merge($tData, array('sex' => intval($p['sex'])));
     }
     $tTime = time();
     //存在干体重修改,则更新干体重记录
     $pDryWeight = !isset($p['dry_weight']) ? '' : floatval($p['dry_weight']);
     $tUMO->begin();
     if (!empty($pDryWeight)) {
         $tData = array_merge($tData, array('dry_weight' => $pDryWeight));
         $tDWLMO = new DryweightlogModel();
         $tDWLRow = $tDWLMO->field('id')->where('uid = ' . $this->tUid . ' and date = \'' . date('Y-m-d', $tTime) . '\'')->fRow();
         if (empty($tDWLRow['id'])) {
             $tDWLData = array('weight' => $pDryWeight, 'uid' => $this->tUid, 'created' => $tTime, 'date' => date('Y-m-d', $tTime), 'month' => date('Y-m', $tTime), 'year' => date('Y', $tTime));
         } else {
             $tDWLData = array('weight' => $pDryWeight, 'updated' => $tTime, 'id' => $tDWLRow['id']);
         }
         if (!$tDWLMO->save($tDWLData)) {
             $tUMO->back();
             Tool_Fnc::ajaxMsg('修改失败 001');
         }
     }
     //存在名字修改,则更新健康档案中的名字字段
     if (isset($p['name']) && !empty($p['name'])) {
         $tUAMO = new UserassessmentModel();
         $tUARow = $tUAMO->field('id,name')->where('uid = ' . $this->tUid)->fRow();
         if (!empty($tUARow['id'])) {
             $tUADatas = array('id' => $tUARow['id'], 'name' => Tool_Fnc::safe_string($p['name']), 'updated' => $tTime);
             if (!$tUAMO->update($tUADatas)) {
                 $tUMO->back();
                 Tool_Fnc::ajaxMsg('修改失败 002');
             }
         } else {
             $tUADatas = array('uid' => $this->tUid, 'name' => Tool_Fnc::safe_string($p['name']), 'created' => $tTime);
             if (!$tUAMO->insert($tUADatas)) {
                 $tUMO->back();
                 Tool_Fnc::ajaxMsg('修改失败 002');
             }
         }
     }
     $tData = array_merge($tData, array('id' => $this->tUid, 'updated' => $tTime));
     if (!$tUMO->update($tData)) {
         $tUMO->back();
         Tool_Fnc::ajaxMsg('修改失败 003');
     }
     $tUMO->commit();
     Tool_Fnc::ajaxMsg('操作成功', 1);
 }
Esempio n. 8
0
 public function yearAction()
 {
     $tDays = 365;
     $tTime = time();
     $tD = date('Y-m-d', $tTime);
     $tD = date('Y-m-d');
     $tDWLMO = new DryweightlogModel();
     $tMO = new R_WeightModel();
     $tYearDatas = $tMO->field('year')->where('uid = ' . $this->tUid)->group('year')->fList();
     #获取记录体重年
     if (empty($tYearDatas[0]['year'])) {
         Tool_Fnc::ajaxMsg('', 1);
     }
     //获得干体重
     $tDWLDatas = $tDWLMO->field('date,weight')->where('uid = ' . $this->tUid)->fList();
     $tDWLArr = array();
     foreach ($tDWLDatas as $tRow) {
         $tDWLArr[$tRow['date']] = $tRow['weight'];
     }
     $tCDate = array();
     $tCYear = array();
     foreach ($tYearDatas as $tYearRow) {
         $tCYear[] = $tYearRow['year'];
         $tDatas = $tMO->field('*')->where('uid = ' . $this->tUid . ' and year = \'' . $tYearRow['year'] . '\'')->fList();
         #查询当月的日期
         foreach ($tDatas as $tDsRow) {
             $tCDate[$tDsRow['date']][] = $tDsRow;
         }
     }
     unset($tYearDatas);
     sort($tCYear);
     $tYDatas = array();
     foreach ($tCYear as $tYVal) {
         $tDays += date('L', strtotime($tYVal . '-01-01'));
         $tDatas = array();
         for ($i = 0; $i < $tDays; $i++) {
             $tDate = date('Y-m-d', strtotime($tYVal . '-01-01') + 86400 * $i);
             if ($tDate > $tD) {
                 continue;
             }
             if (isset($tCDate[$tDate])) {
                 #
                 //计算
                 $tTmp = array();
                 foreach ($tCDate[$tDate] as $tCDRow) {
                     $tStatus = $this->weightstatus($tDWLArr[$tDate], $tCDRow['number']);
                     if (!isset($tTmp[$tDate])) {
                         $tTmp[$tDate] = array();
                     }
                     if (!in_array($tStatus, $tTmp[$tDate])) {
                         $tTmp[$tDate][] = $tStatus;
                     }
                 }
                 foreach ($tTmp as $tTmparr) {
                     if (count($tTmparr) == 2) {
                         foreach ($tTmparr as $tT) {
                             $tDatas[$tT] += 0.5;
                         }
                     } else {
                         if (isset($tDatas[$tTmparr[0]])) {
                             $tDatas[$tTmparr[0]] += 1;
                         } else {
                             $tDatas[$tTmparr[0]] = 1;
                         }
                     }
                 }
                 unset($tTmp);
             } else {
                 #未记录
                 if (isset($tDatas[5])) {
                     $tDatas[5] += 1;
                 } else {
                     $tDatas[5] = 1;
                 }
             }
         }
         $tYDatas[$tYVal] = $tDatas;
         unset($tDatas);
     }
     Tool_Fnc::ajaxMsg('', 1, $tYDatas);
     exit;
 }