Пример #1
0
 public function editAction()
 {
     $p = $_REQUEST;
     $pId = empty($p['id']) ? die('ID不能为空') : intval($p['id']);
     $tMO = new CategoryModel();
     $tCateRow = $tMO->field('*')->where('id = ' . $pId)->fRow();
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $pTitle = empty($p['title']) ? Tool_Fnc::ajaxMsg('分类标题不能为空') : Tool_Fnc::safe_string($p['title']);
         $pName = empty($p['name']) ? Tool_Fnc::ajaxMsg('分类别名不能为空') : Tool_Fnc::safe_string($p['name']);
         $pPid = empty($p['pid']) ? 0 : intval($p['pid']);
         $pKeywords = empty($p['keywords']) ? '' : Tool_Fnc::safe_string($p['keywords']);
         $pDescription = empty($p['description']) ? '' : Tool_Fnc::safe_string($p['description']);
         $tTime = time();
         if (!count($tCateRow)) {
             Tool_Fnc::ajaxMsg('分类不存在');
         }
         $tRow = $tMO->field('count(0) c')->where('name = \'' . $pName . '\' and id <> ' . $pId)->fRow();
         if (!empty($tRow['c'])) {
             Tool_Fnc::ajaxMsg('分类别名不能和其他分类重名');
         }
         $tData = array('title' => $pTitle, 'name' => $pName, 'pid' => $pPid, 'keywords' => $pKeywords, 'description' => $pDescription, 'updated' => $tTime, 'id' => $pId);
         if (!$tMO->update($tData)) {
             Tool_Fnc::ajaxMsg('修改失败');
         }
         Tool_Fnc::ajaxMsg('修改成功', 1);
     }
     $tDatas = $tMO->field('id,pid,name,title')->fList();
     $this->assign('tCatelist', Tool_Fnc::getSortedCategory($tDatas));
     $this->assign('tId', $pId);
     $this->assign('tCateRow', $tCateRow);
 }
Пример #2
0
 public function loginAction()
 {
     if (!$this->valiCaptcha()) {
         return;
     }
     $p = $_REQUEST;
     $pName = empty($p['name']) ? Tool_Fnc::ajaxMsg('用户名不能为空') : Tool_Fnc::safe_string($p['name']);
     $pPasswd = empty($p['passwd']) ? Tool_Fnc::ajaxMsg('密码不能为空') : trim($p['passwd']);
     $pCaptcha = empty($p['captcha']) ? Tool_Fnc::ajaxMsg('验证码为空') : trim($p['captcha']);
     $tMO = new AdminModel();
     $tRow = $tMO->field('*')->where("name = '{$pName}'")->fRow();
     if (!count($tRow)) {
         Tool_Fnc::ajaxMsg('用户不存在');
     }
     if (Tool_Fnc::markmd5($pPasswd, $tRow['private_key']) != $tRow['passwd']) {
         Tool_Fnc::ajaxMsg('密码不正确');
     }
     $_SESSION['admin'] = array('id' => $tRow['id'], 'name' => $tRow['name']);
     if (isset($p['remember']) && $p['remember'] == 'remember') {
         setcookie('admin[id]', $tRow['id'], time() + 60 * 60 * 24 * 365, '/');
         setcookie('admin[name]', $tRow['name'], time() + 60 * 60 * 24 * 365, '/');
     }
     $this->showMsg('', '/admin_user');
     Tool_Fnc::ajaxMsg('', 1);
 }
Пример #3
0
 public function editAction()
 {
     $p = $_REQUEST;
     $pId = empty($p['id']) ? Tool_Fnc::ajaxMsg('请选择食物') : intval($p['id']);
     $pFid = empty($p['fid']) ? Tool_Fnc::ajaxMsg('食物ID不能为空') : intval($p['fid']);
     $pUnit = empty($p['unit']) ? Tool_Fnc::ajaxMsg('单位不能为空') : Tool_Fnc::safe_string($p['unit']);
     $pAmount = empty($p['amount']) ? Tool_Fnc::ajaxMsg('数量不能为空') : floatval($p['amount']);
     $pWeight = empty($p['weight']) ? Tool_Fnc::ajaxMsg('重量不能为空') : floatval($p['weight']);
     $pMtid = empty($p['mt_id']) ? Tool_Fnc::ajaxMsg('餐类型不能为空') : intval($p['mt_id']);
     $tTime = time();
     $tFMO = new FoodModel();
     $tFRow = $tFMO->field('title,protein,thumb_img')->where('id = ' . $pFid)->fRow();
     if (!count($tFRow)) {
         Tool_Fnc::ajaxMsg('食物不存在');
     }
     $tMTMO = new MealtypeModel();
     $tMTRow = $tMTMO->field('name')->where('id = ' . $pMtid)->fRow();
     if (!count($tMTRow)) {
         Tool_Fnc::ajaxMsg('餐类型不存在');
     }
     $tRFDMO = new R_FoodaddModel();
     $tRFRow = $tRFDMO->field('count(*) c')->where(' id =' . $pId)->fRow();
     if (empty($tRFRow['c'])) {
         Tool_Fnc::ajaxMsg('操作异常');
     }
     $tData = array('id' => $pId, 'title' => $tFRow['title'], 'unit' => $pUnit, 'amount' => $pAmount, 'weight' => $pWeight, 'mt_id' => $pMtid, 'mt_name' => $tMTRow['name'], 'created' => $tTime, 'fid' => $pFid, 'uid' => $this->tUid, 'thumb_img' => $tFRow['thumb_img'], 'protein' => $tFRow['protein'] / 100 * $pWeight);
     if (!$tRFDMO->update($tData)) {
         Tool_Fnc::ajaxMsg('更新失败');
     }
     Tool_Fnc::ajaxMsg('更新成功', 1);
 }
Пример #4
0
 public function searchAction()
 {
     $p = $_REQUEST;
     $pKeyword = empty($p['keyword']) ? Tool_Fnc::ajaxMsg('请填写关键词') : Tool_Fnc::safe_string($p['keyword']);
     $tMO = new FoodModel();
     $tImgUrl = Yaf_Registry::get("config")->web->url->img;
     $tDatas = $tMO->field('id fid,title,c_id cateid,c_title cate_title, concat(\'' . $tImgUrl . '\',thumb_img) thumb_img ,tag,protein')->where('title like "%' . $pKeyword . '%"')->fList();
     $tFUMO = new FoodunitsModel();
     foreach ($tDatas as $tKey => $tRow) {
         $tUnits = $tFUMO->field('amount,unit,weight')->where('fid  = ' . $tRow['fid'])->fList();
         $tDatas[$tKey]['units'] = $tUnits;
     }
     Tool_Fnc::ajaxMsg('', 1, $tDatas);
 }
Пример #5
0
 public function addAction()
 {
     $p = $_REQUEST;
     $pName = empty($p['name']) ? '' : Tool_Fnc::safe_string($p['name']);
     $pIdcard = empty($p['idcard']) ? '' : trim($p['idcard']);
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pCode = empty($p['code']) ? '' : trim($p['code']);
     $tTime = time();
     if (!Tool_Validate::name($pName)) {
         Tool_Fnc::ajaxMsg('姓名格式错误');
     }
     if (!Tool_Validate::identify($pIdcard)) {
         Tool_Fnc::ajaxMsg('身份证错误');
     }
     if (!Tool_Validate::az09($pCode)) {
         Tool_Fnc::ajaxMsg('验证码格式错误');
     }
     $tMO = new MemberModel();
     $tRow = $tMO->field('count(0) c')->where('uid = ' . $this->tUid . ' and name = \'' . $pName . '\' and idcard = \'' . $pIdcard . '\'')->fRow();
     if (!empty($tRow['c'])) {
         Tool_Fnc::ajaxMsg('家人已经存在');
     }
     /*
     *  
     name = sys.argv[1]
     sex = sys.argv[2]
     sfz = sys.argv[3]
     phone = sys.argv[4]
     dxcode = sys.argv[5]
     */
     $tSex = substr($pIdcard, strlen($pIdcard) == 15 ? -1 : -2, 1) % 2 ? '男' : '女';
     exec('cd ' . Yaf_Registry::get("config")->guahao->shell->dir . ' reg.py ' . $pName . ' ' . $tSex . ' ' . $pIdcard . ' ' . $pPhone . ' ' . $pCode, $tOut);
     if (!isset($tOut[0])) {
         Tool_Fnc::ajaxMsg('异常错误 002');
     }
     $tRes = json_decode($tOut[0], true);
     $tRes['msg'] = trim($tRes['msg']);
     if ($tRes['status'] == 0 && $tRes['msg'] != '此证件号码已注册过!  重新注册。') {
         Tool_Fnc::ajaxMsg($tRes['msg'], $tRes['status']);
     }
     $tData = array('name' => $pName, 'idcard' => $pIdcard, 'phone' => $pPhone, 'uid' => $this->tUid, 'created' => $tTime);
     if (!$tMO->insert($tData)) {
         Tool_Fnc::ajaxMsg('异常错误 001');
     }
     Tool_Fnc::ajaxMsg('添加成功', 1);
 }
Пример #6
0
 public function indexAction()
 {
     $p = $_REQUEST;
     $pKey = empty($p['key']) ? '' : Tool_Fnc::safe_string($p['key']);
     $tUMO = new UserModel();
     $tWhere = ' 1 = 1 ';
     if (!empty($pKey)) {
         $tWhere .= ' and nickname like \'%' . $pKey . '%\'';
     }
     $tCount = $tUMO->field('count(*) c')->where($tWhere)->fRow();
     $tCnt = empty($tCount['c']) ? 0 : $tCount['c'];
     $pNum = 10;
     $tPG = new Tool_Page($tCnt, $pNum);
     $tDatas = array();
     if (!empty($tCnt)) {
         $tDatas = $tUMO->field('*')->where($tWhere)->order('id asc')->limit($tPG->limit())->fList();
     }
     $this->assign('tShow', $tPG->show());
     $this->assign('tDatas', $tDatas);
 }
Пример #7
0
 public function editAction()
 {
     $p = $_REQUEST;
     $pId = empty($p['id']) ? Tool_Fnc::ajaxMsg('操作错误 001') : intval($p['id']);
     $pFid = empty($p['fid']) ? Tool_Fnc::ajaxMsg('食物ID不能为空') : intval($p['fid']);
     $pUnit = empty($p['unit']) ? Tool_Fnc::ajaxMsg('单位不能为空') : Tool_Fnc::safe_string($p['unit']);
     $pAmount = empty($p['amount']) ? Tool_Fnc::ajaxMsg('数量不能为空') : floatval($p['amount']);
     $pWeight = empty($p['weight']) ? Tool_Fnc::ajaxMsg('重量不能为空') : floatval($p['weight']);
     $pMtid = empty($p['mt_id']) ? Tool_Fnc::ajaxMsg('餐类型不能为空') : intval($p['mt_id']);
     $pDid = empty($p['did']) ? Tool_Fnc::ajaxMsg('DID不能为空') : trim($p['did']);
     $tTime = time();
     if (!Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did格式不正确');
     }
     $tFMO = new FoodModel();
     $tFRow = $tFMO->field('title,tag,thumb_img,protein')->where('id = ' . $pFid)->fRow();
     if (!count($tFRow)) {
         Tool_Fnc::ajaxMsg('食物不存在');
     }
     $tMTMO = new MealtypeModel();
     $tMTRow = $tMTMO->field('name')->where('id = ' . $pMtid)->fRow();
     if (!count($tMTRow)) {
         Tool_Fnc::ajaxMsg('餐类型不存在');
     }
     $tIFDMO = new I_FoodaddModel();
     $tData = array('title' => $tFRow['title'], 'tag' => $tFRow['tag'], 'thumb_img' => $tFRow['thumb_img'], 'unit' => $pUnit, 'amount' => $pAmount, 'weight' => $pWeight, 'mt_id' => $pMtid, 'mt_name' => $tMTRow['name'], 'fid' => $pFid, 'did' => $pDid, 'protein' => $tFRow['protein'] / 100 * $pWeight);
     $tIFDRow = $tIFDMO->field('id')->where(' id = ' . $pId . ' and did = \'' . $pDid . '\' and mt_id = ' . $pMtid)->fRow();
     if (!empty($tIFDRow['id'])) {
         $tData = array_merge($tData, array('updated' => $tTime, 'id' => $tIFDRow['id']));
         if (!$tIFDMO->update($tData)) {
             Tool_Fnc::ajaxMsg('操作失败 002');
         }
     } else {
         $tData = array_merge($tData, array('created' => $tTime));
         if (!$tIFDMO->insert($tData)) {
             Tool_Fnc::ajaxMsg('操作失败 003');
         }
     }
     Tool_Fnc::ajaxMsg('操作成功', 1);
 }
Пример #8
0
 public function addAction()
 {
     $p = $_REQUEST;
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $pName = empty($p['name']) ? Tool_Fnc::ajaxMsg('用户名不能为空') : Tool_Fnc::safe_string($p['name']);
         Tool_Validate::az09($pName) ? '' : Tool_Fnc::ajaxMsg('用户名格式为a-zA-Z_-组成');
         $pPasswd = empty($p['passwd']) ? Tool_Fnc::ajaxMsg('密码不能为空') : trim($p['passwd']);
         $pRepasswd = empty($p['repasswd']) ? Tool_Fnc::ajaxMsg('重复密码不能为空') : trim($p['repasswd']);
         strlen($pPasswd) < 6 || strlen($pRepasswd) < 6 ? Tool_Fnc::ajaxMsg('密码长度至少为6位') : '';
         if ($pPasswd !== $pRepasswd) {
             Tool_Fnc::ajaxMsg('两次密码不一置');
         }
         $pPrivateKey = Tool_Fnc::newrand();
         $pPasswd = Tool_Fnc::markmd5($pPasswd, $pPrivateKey);
         $tDatas = array('name' => $pName, 'passwd' => $pPasswd, 'private_key' => $pPrivateKey);
         $tAM = new AdminModel();
         if (!$tAM->insert($tDatas)) {
             Tool_Fnc::ajaxMsg('新增管理员失败');
         }
         Tool_Fnc::ajaxMsg('添加成功', 1);
     }
 }
Пример #9
0
 public function editAction()
 {
     $p = $_REQUEST;
     $pId = empty($p['id']) ? 0 : intval($p['id']);
     $tAMO = new ArticleModel();
     $tCateMO = new CategoryModel();
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $pTitle = empty($p['title']) ? Tool_Fnc::ajaxMsg('文章标题不能为空') : Tool_Fnc::safe_string($p['title']);
         $pCateid = empty($p['cate_id']) ? 0 : intval($p['cate_id']);
         $pContent = empty($p['content']) ? Tool_Fnc::ajaxMsg('内容不能为空') : Tool_Fnc::safe_string($p['content']);
         $pHeadimg = empty($p['head_img']) ? '' : Tool_Fnc::safe_string($p['head_img']);
         $pDescription = empty($p['description']) ? '' : Tool_Fnc::safe_string($p['description']);
         $pSource = empty($p['source']) ? '' : Tool_Fnc::safe_string($p['source']);
         $pInitview = empty($p['initview']) ? '0' : intval($p['initview']);
         $pStatus = empty($p['status']) ? '0' : intval($p['status']);
         $pPushtime = empty($p['push_time']) ? Tool_Fnc::ajaxMsg('请选择日期') : Tool_Fnc::safe_string($p['push_time']);
         $pPushtime = time($pPushtime);
         $tTime = time();
         $tCateRow = $tCateMO->field('*')->where('id = ' . $pCateid)->fRow();
         if (empty($tCateRow['id'])) {
             Tool_Fnc::ajaxMsg('请选择文章分类');
         }
         $tHeadimg = '';
         if (!empty($_FILES['img'])) {
             $tImgurl = '/articleimg/' . date('Y') . '/' . date('m') . '/';
             $tDir = APPLICATION_PATH . '/public' . $tImgurl;
             $tUpload = new Tool_Upload($_FILES['img'], $tDir);
             $tSavename = $tUpload->getSaveName();
             $tExt = $tUpload->extension;
             $tFile = $tSavename . '.' . $tExt;
             $tRes = $tUpload->upload($tSavename);
             if ($tRes == 1) {
                 $tHeadimg = Yaf_Registry::get("config")->web->url->staticimg . $tImgurl . $tFile;
                 if (!empty($pHeadimg)) {
                     unlink(APPLICATION_PATH . '/public' . $pHeadimg);
                 }
             }
         }
         $tHeadimg = empty($tHeadimg) ? $pHeadimg : $tHeadimg;
         $tData = array('head_img' => $tHeadimg, 'title' => $pTitle, 'content' => $pContent, 'description' => $pDescription, 'cate_id' => $pCateid, 'cate_name' => $tCateRow['name'], 'cate_title' => $tCateRow['title'], 'source' => $pSource, 'initview' => $pInitview, 'updated' => $tTime, 'status' => $pStatus, 'push_time' => $pPushtime, 'id' => $pId);
         if (!$tAMO->update($tData)) {
             Tool_Fnc::ajaxMsg('修改失败');
         }
         Tool_Fnc::ajaxMsg('修改成功', 1);
     }
     $tDatas = $tCateMO->field('id,pid,name,title')->fList();
     $this->assign('tCatelist', Tool_Fnc::getSortedCategory($tDatas));
     $tAinfo = $tAMO->field('*')->where('id = ' . $pId)->fRow();
     $this->assign('tAinfo', $tAinfo);
     $this->assign('tId', $pId);
 }
Пример #10
0
 public function sloginAction()
 {
     $p = $_REQUEST;
     $pPlatform = empty($p['platform']) ? 0 : intval(trim($p['platform']));
     $pIconurl = empty($p['iconurl']) ? '' : trim($p['iconurl']);
     $pUsid = empty($p['usid']) ? '' : trim($p['usid']);
     $pUsername = empty($p['username']) ? '' : Tool_Fnc::safe_string($p['username']);
     $pDid = empty($p['did']) ? '' : trim($p['did']);
     $tTime = time();
     if (empty($pPlatform)) {
         Tool_Fnc::ajaxMsg('请选择第三方平台');
     }
     if (!empty($pIconurl) && !Tool_Validate::url($pIconurl)) {
         Tool_Fnc::ajaxMsg('头像不是有效地址');
     }
     if (empty($pUsid) || !Tool_Validate::safe($pUsid)) {
         Tool_Fnc::app('usid 有问题');
     }
     #if(empty($pUsername) || !Tool_Validate::safe($pUsername)){Tool_Fnc::ajaxMsg('昵称有问题');}
     if (empty($pDid) || !Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did error');
     }
     $tMAMO = new Web_MembersaidModel();
     $tMMO = new Web_MembersModel();
     $tMAMO->begin();
     //判断是否授权过
     $tUid = 0;
     $tMARow = $tMAMO->field('id,username,iconurl,mid')->where('usid = \'' . $pUsid . '\' and platform = ' . $pPlatform)->fRow();
     if (empty($tMARow['id'])) {
         #第一次授权
         $tKey = Tool_Fnc::newrand(4);
         $tData = array('mem_img' => $pIconurl, 'mem_name' => $pUsername, 'mem_key' => $tKey);
         if (!($tUid = $tMMO->insert($tData))) {
             $tMAMO->back();
             Tool_Fnc::ajaxMsg('操作失败:001');
         }
         $tData = array('platform' => $pPlatform, 'iconurl' => $pIconurl, 'usid' => $pUsid, 'created' => $tTime, 'username' => $pUsername, 'mid' => $tUid, 'ip' => Tool_Fnc::realip());
         if (!$tMAMO->insert($tData)) {
             $tMAMO->back();
             Tool_Fnc::ajaxMsg('操作失败:002');
         }
     } else {
         $tUid = $tMARow['mid'];
         $tMRow = $tMMO->field('mem_name,mem_img')->where('id_web_members = ' . $tMARow['mid'])->fRow();
         $tMData = array();
         $tMAData = array();
         if ($tMARow['username'] == $tMRow['mem_name'] && $tMRow['mem_name'] != $pUsername) {
             #如果单独修改昵称 不予第三方同步
             $tMData = array_merge($tMData, array('mem_name' => $pUsername));
             $tMAData = array_merge($tMAData, array('username' => $pUsername));
         }
         if ($tMARow['iconurl'] == $tMRow['mem_img'] && $tMRow['mem_img'] != $pIconurl) {
             #如果单独修改头像 不予第三方同步
             $tMData = array_merge($tMData, array('mem_img' => $pIconurl));
             $tMAData = array_merge($tMAData, array('iconurl' => $pIconurl));
         }
         if (count($tMData)) {
             $tMData = array_merge($tMData, array('id_web_members' => $tMARow['mid']));
             if (!$tMMO->update($tMData)) {
                 $tMAMO->back();
                 Tool_Fnc::ajaxMsg('操作失败:003');
             }
             $tData = array('mid' => $tMARow['mid'], 'updated' => $tTime);
             $tMAData = array_merge($tMAData, $tData);
             if (!$tMAMO->update($tMAData)) {
                 $tMAMO->back();
                 Tool_Fnc::ajaxMsg('操作失败:004');
             }
         }
     }
     //did入库
     $tMDMO = new Web_MembersdidModel();
     $tMDRow = $tMDMO->field('count(0) c')->where('mid = ' . $tUid . ' and did = \'' . $pDid . '\'')->fRow();
     if (empty($tMDRow['c'])) {
         $tData = array('mid' => $tUid, 'did' => $pDid, 'created' => $tTime);
         $tMDMO->insert($tData);
     }
     $tMAMO->commit();
     $tTokenarr = $this->creattoken($tUid);
     $tISMO = new Web_IncognitosheetsModel();
     $tISMO->incognito_real($pDid, $tUid);
     Tool_Fnc::ajaxMsg("登录成功", 1, $tTokenarr);
     //登录成功返回token
 }
Пример #11
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);
 }
Пример #12
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);
 }
Пример #13
0
 public function foodAction()
 {
     $p = $_REQUEST;
     $pKey = empty($p['term']) ? '' : Tool_Fnc::safe_string($p['term']);
     $tMO = new FoodModel();
     if (!empty($pKey)) {
         $tWhere = 'title like "%' . $pKey . '%"';
     }
     if (!empty($pKey)) {
         $tDatas = $tMO->field('id,title,thumb_img')->where($tWhere)->limit(5)->fList();
     } else {
         $tDatas = $tMO->field('id,title,thumb_img')->limit(5)->fList();
     }
     Yaf_Dispatcher::getInstance()->autoRender(FALSE);
     die(json_encode($tDatas));
 }
Пример #14
0
 public function foodAction()
 {
     $p = $_REQUEST;
     $pKey = empty($p['term']) ? '' : Tool_Fnc::safe_string($p['term']);
     $tMO = new FoodModel();
     if (!empty($pKey)) {
         $tWhere = 'title like "%' . $pKey . '%"';
     }
     if (!empty($pKey)) {
         $tDatas = $tMO->field('id,title,tag,protein,thumb_img')->where($tWhere)->limit(5)->fList();
     } else {
         $tDatas = $tMO->field('id,title,tag,protein,thumb_img')->limit(5)->fList();
     }
     $tFU = new FoodunitsModel();
     foreach ($tDatas as $k => &$v) {
         $v['unit'] = $tFU->field('id,amount,unit,weight,calory')->where(' fid = ' . $v['id'])->fList();
         $v['protein'] = floatval($v['protein']) / 100;
     }
     Yaf_Dispatcher::getInstance()->autoRender(FALSE);
     die(json_encode($tDatas));
 }
Пример #15
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']));
 }
Пример #16
0
 public function editAction()
 {
     $p = $_REQUEST;
     $pId = empty($p['id']) ? die('ID不能为空') : intval($p['id']);
     $tMO = new FoodModel();
     $tCateRow = $tMO->where('id = ' . $pId)->fRow();
     $this->assign('tId', $pId);
     $this->assign('tCateRow', $tCateRow);
     $tFT = new FoodtagModel();
     $tTagList = $tFT->field('id,concat(title,\'_tag\') title,fid,flag')->where('fid = ' . $pId)->fList();
     foreach ($tTagList as $v) {
         if (is_array($v)) {
             foreach ($v as $k => $v1) {
                 if ($k == 'title' || $k == 'flag') {
                     if ($k == 'title') {
                         $t1 = $v1;
                     } elseif ($k == 'flag') {
                         $t2 = $v1;
                     }
                 }
             }
             $tTagRow[$t1] = $t2;
         }
     }
     $this->assign('tTagRow', isset($tTagRow) ? $tTagRow : null);
     $tTP = new FoodcategoryModel();
     $pType = $tTP->field('id,title')->fList();
     $this->assign('pType', $pType);
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $pPhoto = isset($_FILES['photo']) ? $_FILES['photo'] : null;
         if ($pPhoto) {
             $subPath = date("Ymd", time());
             $tUpload = new Tool_Upload($pPhoto, APPLICATION_PATH . '/public/upload/food/' . $subPath . '/');
             $tSavename = $tUpload->getSaveName();
             $tRes = $tUpload->upload($tSavename);
             $tExt = $tUpload->extension;
             if ($tRes == 1) {
                 $tUpload->createThumb('300', '300', APPLICATION_PATH . '/public/upload/food/' . $subPath . '_small/');
                 $tSFile = '/upload/food/' . $subPath . '_small/' . $tSavename . '.' . $tExt;
                 $tFile = '/upload/food/' . $subPath . '/' . $tSavename . '.' . $tExt;
             } else {
                 Tool_Fnc::ajaxMsg('图片上传失败');
                 die;
             }
         }
         $pTitle = empty($p['title']) ? Tool_Fnc::ajaxMsg('食物名称不能为空') : Tool_Fnc::safe_string($p['title']);
         $pProtein = empty($p['protein']) ? Tool_Fnc::ajaxMsg('蛋白质不能为空') : floatval($p['protein']);
         $pCalory = !isset($p['calory']) ? '' : floatval($p['calory']);
         $pFat = !isset($p['fat']) ? '' : floatval($p['fat']);
         $pCarbohydrate = !isset($p['carbohydrate']) ? '' : floatval($p['carbohydrate']);
         $pFiber = !isset($p['fiber_dietary']) ? '' : floatval($p['fiber_dietary']);
         $pCalcium = !isset($p['calcium']) ? '' : floatval($p['calcium']);
         $pZinc = !isset($p['zinc']) ? '' : floatval($p['zinc']);
         $pVitamin_a = !isset($p['vitamin_a']) ? '' : floatval($p['vitamin_a']);
         $pVitamin_c = !isset($p['vitamin_c']) ? '' : floatval($p['vitamin_c']);
         $pMagnesium = !isset($p['magnesium']) ? '' : floatval($p['magnesium']);
         $pSelenium = !isset($p['selenium']) ? '' : floatval($p['selenium']);
         $pCopper = !isset($p['copper']) ? '' : floatval($p['copper']);
         $pPhosphor = !isset($p['phosphor']) ? '' : floatval($p['phosphor']);
         $pNiacin = !isset($p['niacin']) ? '' : floatval($p['niacin']);
         $pVitamin_e = !isset($p['vitamin_e']) ? '' : floatval($p['vitamin_e']);
         $pManganese = !isset($p['manganese']) ? '' : floatval($p['manganese']);
         $pCholesterol = !isset($p['cholesterol']) ? '' : floatval($p['cholesterol']);
         $pIron = !isset($p['iron']) ? '' : floatval($p['iron']);
         $pKalium = !isset($p['kalium']) ? '' : floatval($p['kalium']);
         $pNatrium = !isset($p['natrium']) ? '' : floatval($p['natrium']);
         $pThiamine = !isset($p['thiamine']) ? '' : floatval($p['thiamine']);
         $pLactoflavin = !isset($p['lactoflavin']) ? '' : floatval($p['lactoflavin']);
         $pCarotene = !isset($p['carotene']) ? '' : floatval($p['carotene']);
         $pTag = array();
         empty($p['calory_tag']) ? '' : ($pTag['calory'] = Tool_Fnc::safe_string($p['calory_tag']));
         empty($p['protein_tag']) ? '' : ($pTag['protein'] = Tool_Fnc::safe_string($p['protein_tag']));
         empty($p['fat_tag']) ? '' : ($pTag['fat'] = Tool_Fnc::safe_string($p['fat_tag']));
         empty($p['carbohydrate_tag']) ? '' : ($pTag['carbohydrate'] = Tool_Fnc::safe_string($p['carbohydrate_tag']));
         empty($p['fiber_dietary_tag']) ? '' : ($pTag['fiber_dietary'] = Tool_Fnc::safe_string($p['fiber_dietary_tag']));
         $pTags = empty($pTag) ? '' : implode('|', $pTag);
         $pSuggest = $p['suggest'];
         $pUpdated = time();
         $pCid = empty($p['c_id']) ? Tool_Fnc::ajaxMsg('食物没有分类') : floatval($p['c_id']);
         $tRow = $tTP->field('id,title')->where('id= \'' . $pCid . '\'')->fRow();
         $tData = array('id' => $pId, 'title' => $pTitle, 'calory' => $pCalory, 'protein' => $pProtein, 'fat' => $pFat, 'carbohydrate' => $pCarbohydrate, 'fiber_dietary' => $pFiber, 'calcium' => $pCalcium, 'zinc' => $pZinc, 'vitamin_a' => $pVitamin_a, 'vitamin_c' => $pVitamin_c, 'magnesium' => $pMagnesium, 'selenium' => $pSelenium, 'copper' => $pCopper, 'phosphor' => $pPhosphor, 'niacin' => $pNiacin, 'vitamin_e' => $pVitamin_e, 'manganese' => $pManganese, 'cholesterol' => $pCholesterol, 'iron' => $pIron, 'kalium' => $pKalium, 'natrium' => $pNatrium, 'thiamine' => $pThiamine, 'lactoflavin' => $pLactoflavin, 'carotene' => $pCarotene, 'tag' => $pTags, 'updated' => $pUpdated, 'suggest' => $pSuggest, 'c_id' => $tRow['id'], 'c_title' => $tRow['title']);
         $tData['large_img'] = isset($tFile) ? $tFile : $p['large_img'];
         $tData['thumb_img'] = isset($tSFile) ? $tSFile : $p['thumb_img'];
         $tFF = new FoodtagModel();
         if ($tMO->update($tData)) {
             $tFF->where(' fid =' . $pId)->del();
             foreach ($pTag as $k => $v) {
                 $values['title'] = $k;
                 $values['fid'] = $pId;
                 $values['flag'] = $v;
                 $tFF->insert($values);
             }
             Tool_Fnc::ajaxMsg('修改成功', 1);
         } else {
             Tool_Fnc::ajaxMsg('修改失败');
         }
     }
 }
Пример #17
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);
             $tStart = date('Y-m-d', $tTime - 86400 * 364);
         } else {
             $tTime = time();
             $tEnd = date('Y-m-d');
             $tStart = date('Y-m-d', $tTime - 86400 * 363);
         }
     } else {
         if (!empty($pDate)) {
             $tStart = date('Y-m-d', $tTime + 86400);
             $tEnd = date('Y-m-d', $tTime + 86400 * 364);
         } else {
             $tTime = time();
             $tStart = date('Y-m-d');
             $tEnd = date('Y-m-d', $tTime + 86400 * 363);
         }
     }
     $tWhere .= ' and date between \'' . $tStart . '\' and \'' . $tEnd . '\'';
     $tMO = new R_BloodpressureModel();
     $tSql = 'select * from (select id,type,high,low,date from ' . $tMO->table . ' where uid = ' . $this->tUid . $tWhere . ' order by date,type desc) w group by date';
     $tData = $tMO->query($tSql);
     #血压开始时间
     $tSql = 'select date from ' . $tMO->table . ' where uid = ' . $this->tUid . ' order by date asc limit 1';
     $tStartBlood = $tMO->query($tSql);
     $tStartBloodDate = empty($tStartBlood[0]['date']) ? '' : $tStartBlood[0]['date'];
     Tool_Fnc::ajaxMsg('', 1, array('blood' => $tData, 'blood_start_date' => $tStartBloodDate));
 }
Пример #18
0
 public function editAction()
 {
     $p = $_REQUEST;
     $tId = empty($p['id']) ? die('id不能为空') : intval($p['id']);
     $this->assign('tId', $tId);
     $tBMO = new BannerModel();
     $tRow = $tBMO->where(' id = ' . $tId)->fRow();
     $this->assign('tRow', $tRow);
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $pPhoto = isset($_FILES['img']) ? $_FILES['img'] : null;
         if ($pPhoto) {
             $subPath = date("Ymd", time());
             $tUpload = new Tool_Upload($pPhoto, APPLICATION_PATH . '/public/upload/banner/' . $subPath . '/');
             $tSavename = $tUpload->getSaveName();
             $tRes = $tUpload->upload($tSavename);
             $tExt = $tUpload->extension;
             if ($tRes == 1) {
                 $tUpload->createThumb('200', '200', APPLICATION_PATH . '/public/upload/banner/' . $subPath . '_small/');
                 $tSFile = '/upload/banner/' . $subPath . '_small/' . $tSavename . '.' . $tExt;
                 $tFile = '/upload/banner/' . $subPath . '/' . $tSavename . '.' . $tExt;
             } else {
                 Tool_Fnc::ajaxMsg('图片上传失败');
                 die;
             }
         }
         //$pUrl = empty($p['url'])?Tool_Fnc::ajaxMsg('地址不能为空'):Tool_Fnc::safe_string($p['url']);
         //$pType = empty($p['type'])?Tool_Fnc::ajaxMsg('类型id不能为空'):Tool_Fnc::safe_string($p['type']);
         //$pTypeName = empty($p['type_name'])?Tool_Fnc::ajaxMsg('类型不为空'):Tool_Fnc::safe_string($p['type_name']);
         $pImg = Tool_Fnc::safe_string($p['img']);
         $tTime = time();
         $tDatas = array('id' => $tId, 'updated' => $tTime);
         $tDatas['img'] = empty($tSFile) ? $pImg : $tSFile;
         if (!$tBMO->update($tDatas)) {
             Tool_Fnc::ajaxMsg('更新失败');
         }
         Tool_Fnc::ajaxMsg('更新成功', 1);
     }
 }