예제 #1
0
 public function diethomeAction()
 {
     $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();
     $tDWLMO = new DryweightlogModel();
     $tDatas = array();
     $tDWLRow['weight'] = $tDWLMO->is_dryweight($this->tUid, $pDate);
     $tArr = $tFMO->diet('protein', $tDWLRow['weight']);
     $tDatas['protein']['total'] = $tArr['start'];
     $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);
     $tDatas['protein']['surplus'] = 0;
     $tDatas['protein']['number'] = 0;
     if (!count($tList)) {
         Tool_Fnc::ajaxMsg('', 1, $tDatas);
     }
     #已经摄取
     foreach ($tList as $tRow) {
         $tDatas['protein']['number'] += $tRow['protein'] / 100 * $tRow['weight'];
         #蛋白质
     }
     unset($tList);
     #应摄取
     #蛋白质
     $tSurplus = $tArr['end'] - $tDatas['protein']['number'];
     $tDatas['protein']['surplus'] = $tSurplus <= 0 ? 0 : $tSurplus;
     Tool_Fnc::ajaxMsg('', 1, $tDatas);
     exit;
 }
예제 #2
0
 public function dietAction()
 {
     $p = $_REQUEST;
     $pDate = empty($p['date']) ? Tool_Fnc::ajaxMsg('日期不能为空') : trim($p['date']);
     $pDid = empty($p['did']) ? Tool_Fnc::ajaxMsg('DID不能为空') : trim($p['did']);
     if (!Tool_Validate::az09($pDid)) {
         Tool_Fnc::ajaxMsg('did格式不正确');
     }
     if (!Tool_Validate::is_date($pDate)) {
         Tool_Fnc::ajaxMsg('日期不正确');
     }
     $tFAMO = new I_FoodaddModel();
     $tFMO = new FoodModel();
     $tSql = 'select * from (select fid,unit,amount,weight from ' . $tFAMO->table . ' where did = \'' . $pDid . '\' 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);
         $tDatas['carbohydrate']['number'] = round($tRow['carbohydrate'] / 100 * $tRow['weight'], 2);
         #碳水化合物
         $tDatas['phosphor']['number'] = round($tRow['phosphor'] / 100 * $tRow['weight'] / 1000, 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);
         $tDatas['kalium']['number'] = round($tRow['kalium'] / 100 * $tRow['weight'] / 1000, 2);
         #钾
         $tDatas['natrium']['number'] = round($tRow['natrium'] / 100 * $tRow['weight'] / 1000, 2);
         #钠
         $tDatasother['thiamine']['number'] = round($tRow['thiamine'] / 100 * $tRow['weight'], 2);
         $tDatas['protein']['number'] = round($tRow['protein'] / 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);
     }
     unset($tList);
     #钠
     $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;
     #钾
     #        $tArr = $tFMO->diet('kalium');
     #        $tDatas['kalium']['total'] = implode('-',$tArr);
     #        $tSurplus = $tArr['end']-$tDatas['kalium']['number'];
     #        $tDatas['kalium']['surplus'] = ($tSurplus <= 0)?0:$tSurplus;
     $tDatas['kalium']['total'] = 10;
     $tDatas['kalium']['surplus'] = 0;
     $tDatas['protein']['total'] = 0;
     $tDatas['protein']['surplus'] = 0;
     $tDatas['carbohydrate']['total'] = 0;
     $tDatas['carbohydrate']['surplus'] = 0;
     Tool_Fnc::ajaxMsg('', 1, array('main' => $tDatas, 'other' => $tDatasother));
     exit;
 }