public function editmedAction() { $p = $_REQUEST; //判断用户是否为白求恩用户 $tUMO = new UserModel(); $tURow = $tUMO->field('user_type')->where(' id = ' . $this->tUid)->fRow(); if ($tURow['user_type'] == 1) { Tool_Fnc::ajaxMsg('操作错误'); } $pProvinces = empty($p['provinces']) ? Tool_Fnc::ajaxMsg('省份不能为空') : Tool_Fnc::safe_string($p['provinces']); $pCities = empty($p['cities']) ? Tool_Fnc::ajaxMsg('城市不能为空') : Tool_Fnc::safe_string($p['cities']); $pName = empty($p['name']) ? Tool_Fnc::ajaxMsg('名称不能为空') : Tool_Fnc::safe_string($p['name']); $tTime = time(); //获取天气 $tWeatherCities = array('北京', '天津', '上海', '重庆'); if (in_array($pProvinces, $tWeatherCities)) { $tWeatherCity = $pProvinces; } else { $tWeatherCity = $pCities; } $tWeather = Tool_Fnc::weather_juhe($tWeatherCity); $tData = array('provinces' => $pProvinces, 'cities' => $pCities, 'name' => $pName, 'today_weather' => $tWeather['today_weather'], 'tomorrow_weather' => $tWeather['tomorrow_weather']); //更新透析中心 $tCMO = new CenterModel(); $sql = "select id from {$tCMO->table} where provinces = '{$pProvinces}' and cities = '{$pCities}' and name ='{$pName}' and type =0 "; $tCMOList = $tCMO->query($sql); if (empty($tCMOList[0]['id'])) { $tData['created'] = $tTime; if (!($tMedicalId = $tCMO->insert($tData))) { Tool_Fnc::ajaxMsg('插入失败'); } } else { $tData['updated'] = $tTime; $tData['id'] = $tCMOList[0]['id']; if (!$tCMO->update($tData)) { Tool_Fnc::ajaxMsg('更新失败'); } } $tUAMO = new UserassessmentModel(); $tUARow = $tUAMO->field('id')->where(' uid = ' . $this->tUid)->fRow(); //更新健康档案 if (isset($tMedicalId)) { $tUAData = array('medical_id' => $tMedicalId); } else { $tUAData = array('medical_id' => $tCMOList[0]['id']); } if (empty($tUARow['id'])) { $tUAData = array_merge($tUAData, array('uid' => $this->tUid, 'created' => $tTime)); if (!$tUAMO->insert($tUAData)) { Tool_Fnc::ajaxMsg('插入失败'); } } else { $tUAData = array_merge($tUAData, array('id' => $tUARow['id'], 'updated' => $tTime)); if (!$tUAMO->update($tUAData)) { Tool_Fnc::ajaxMsg('更新失败'); } } //更新用户表中的字段 $tUData = array('id' => $this->tUid, 'medical_addr' => $pName, 'updated' => $tTime); if (isset($tMedicalId)) { $tUData['center_id'] = $tMedicalId; } else { $tUData['center_id'] = $tCMOList[0]['id']; } if (!$tUMO->update($tUData)) { Tool_Fnc::ajaxMsg('更新失败'); } Tool_Fnc::ajaxMsg('', 1); }