示例#1
0
 public function daily_recipesAction()
 {
     $tDate = date('Y-m-d');
     $tMO = new DailyrecipesModel();
     $tRow = $tMO->field('day_date')->group('day_date')->order('day_date desc')->limit('1')->fRow();
     if (!empty($tRow['day_date'])) {
         $tDate = $tRow['day_date'];
     }
     $tFUMO = new FoodunitsModel();
     $tImgUrl = Yaf_Registry::get("config")->web->url->img;
     $tDatas = $tMO->field('mt_name,mt_id,title,unit,amount,weight,fid,tag, concat(\'' . $tImgUrl . '\',thumb_img) thumb_img,protein')->where('day_date = \'' . $tDate . '\'')->order('mt_id asc')->fList();
     $tDatasnew = array();
     foreach ($tDatas as $tRow) {
         $tUnits = $tFUMO->field('amount,unit,weight')->where('fid  = ' . $tRow['fid'])->fList();
         $tDatasnew[$tRow['mt_id']][] = array_merge($tRow, array('units' => $tUnits));
     }
     Tool_Fnc::ajaxMsg('', 1, $tDatasnew);
 }
示例#2
0
 public function listAction()
 {
     $p = $_REQUEST;
     $pDate = empty($p['date']) ? Tool_Fnc::ajaxMsg('日期不能为空') : trim($p['date']);
     if (!Tool_Validate::is_date($pDate)) {
         Tool_Fnc::ajaxMsg('日期不正确');
     }
     $tImgUrl = Yaf_Registry::get("config")->web->url->img;
     $tFAMO = new R_FoodaddModel();
     $tFUMO = new FoodunitsModel();
     $tFADatas = $tFAMO->field('id,fid,mt_id,mt_name,title,unit,amount,weight,protein,tag,concat(\'' . $tImgUrl . '\',thumb_img) thumb_img')->where('uid = ' . $this->tUid . ' and created >=' . strtotime($pDate) . ' and created <=' . strtotime($pDate . ' 23:59:59'))->fList();
     $tDatas = array();
     foreach ($tFADatas as $tKey => $tRow) {
         $tUnits = $tFUMO->field('amount,unit,weight')->where('fid  = ' . $tRow['fid'])->fList();
         #$tFADatas[$tKey]['units'] = $tUnits;
         $tDatas[$tRow['mt_id']][] = array_merge($tRow, array('units' => $tUnits));
     }
     Tool_Fnc::ajaxMsg('', 1, $tDatas);
 }
示例#3
0
 public function normalAction()
 {
     $p = $_REQUEST;
     $tFMO = new FoodModel();
     $tImgUrl = Yaf_Registry::get("config")->web->url->img;
     $tSql = 'select id fid,title,c_id cateid,c_title cate_title, concat(\'' . $tImgUrl . '\',thumb_img) thumb_img ,tag,protein from ' . $tFMO->table . ' where suggest = 1 order by count desc,protein desc';
     $tDRDatas = $tFMO->query($tSql);
     $tFUMO = new FoodunitsModel();
     foreach ($tDRDatas as &$v) {
         $v['units'] = $tFUMO->field('unit,amount,weight')->where(' fid = ' . $v['fid'])->fList();
     }
     Tool_Fnc::ajaxMsg('', 1, $tDRDatas);
 }
示例#4
0
 public function addfoodAction()
 {
     $p = $_REQUEST;
     $pFid = empty($p['id']) ? Tool_Fnc::ajaxMsg('错误异常 001') : intval($p['id']);
     $tFMO = new FoodModel();
     $tRow = $tFMO->field('id,title,tag,protein,thumb_img')->where('id =' . $pFid)->fRow();
     $tRow['protein'] = floatval($tRow['protein']) / 100;
     $tFUMO = new FoodunitsModel();
     $tUnit = $tFUMO->field('id,amount,unit,weight,calory')->where(' fid = ' . $pFid)->fList();
     $tMTMO = new MealtypeModel();
     $pType = $tMTMO->field('id,name')->fList();
     $this->assign('tRow', $tRow);
     $this->assign('pUnit', $tUnit);
     $this->assign('pType', $pType);
 }