Exemplo n.º 1
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));
 }