Exemple #1
0
 public function indexAction()
 {
     $tWeek = date('w', time());
     $tODTMO = new OrdinarydialysistimeModel();
     $tODTRow = $tODTMO->field('week,time,time_code')->where('uid = ' . $this->tUid)->fRow();
     $tODTRow['week'] = empty($tODTRow['week']) ? -1 : $tODTRow['week'];
     $tODTRow['time'] = empty($tODTRow['time']) ? '' : $tODTRow['time'];
     $tODTRow['time_code'] = empty($tODTRow['time_code']) ? '' : $tODTRow['time_code'];
     $tArr = explode('|', $tODTRow['week']);
     foreach ($tArr as $k => &$v) {
         if ($v == "" || $v == null) {
             unset($tArr[$k]);
         }
     }
     $tUMO = new UserModel();
     $tURow = $tUMO->field('center_id')->where(' id = ' . $this->tUid . ' and user_type = 0')->fRow();
     $tCMO = new CenterModel();
     $tCRow = $tCMO->field('name,today_weather')->where('id =' . $tURow['center_id'])->fRow();
     $tCRow['name'] = empty($tCRow['name']) ? '' : $tCRow['name'];
     $tCRow['today_weather'] = empty($tCRow['today_weather']) ? '' : $tCRow['today_weather'];
     $tArray = array();
     $tArray['time'] = $tODTRow['time'];
     $tArray['time_code'] = $tODTRow['time_code'];
     $tArray['medical_addr'] = $tCRow['name'];
     $tArray['today_weather'] = $tCRow['today_weather'];
     if (in_array($tWeek, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', time())), $tArray));
     }
     if (in_array(($tWeek + 1) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+1day'))), $tArray));
     }
     if (in_array(($tWeek + 2) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+2day'))), $tArray));
     }
     if (in_array(($tWeek + 3) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+3day'))), $tArray));
     }
     if (in_array(($tWeek + 4) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+4day'))), $tArray));
     }
     if (in_array(($tWeek + 5) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+5day'))), $tArray));
     }
     if (in_array(($tWeek + 6) % 7, $tArr)) {
         Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => date('Y-m-d', strtotime('+6day'))), $tArray));
     }
     Tool_Fnc::ajaxMsg('', 1, array_merge(array('date' => ''), $tArray));
 }
 public function indexAction()
 {
     $tTime = time();
     $tH = date('H', $tTime);
     $tRedis = Cache_Redis::instance();
     $tMO = new OrdinarydialysistimeModel();
     $tODDMO = new OrdinarydialysisdateModel();
     $tUMO = new UserModel();
     $tUDMO = new UserdidModel();
     $tUAMO = new UserassessmentModel();
     $tCMO = new CenterModel();
     if ($tH >= 7 && $tH <= 11) {
         #今日提醒
         $tWeek = date('w', $tTime);
         $tDate = date('Y-m-d', $tTime);
         $tWhere = ' time_code in (2,3)';
         $tDatas = $tMO->field('uid,time_code,time')->where($tWhere . ' and week like \'%' . $tWeek . '%\'')->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('today_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTimecodestr = $tRow['time_code'] == 2 ? '下午' : '晚上';
             $tTimecodestr .= $tRow['time'];
             $tTpl_val = '#timecodestr#=今日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['today_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx')));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime) . $tTimecodestr;
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['today_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
             $tODDRow = $tODDMO->field('count(0) c')->where('uid = ' . $tRow['uid'] . ' and date = \'' . $tDate . '\'')->fRow();
             if (!empty($tODDRow['c'])) {
                 continue;
             }
             #添加透析日期
             $tData = array('date' => $tDate, 'uid' => $tRow['uid'], 'time_code' => $tRow['time_code'], 'created' => $tTime);
             $tODDMO->insert($tData);
         }
     } elseif ($tH >= 13 && $tH <= 21) {
         #第二天上午
         $tWeek = date('w', $tTime + 86400);
         $tDate = date('Y-m-d', $tTime + 86400);
         $tWhere = ' time_code = 1';
         $tDatas = $tMO->field('uid,time_code,time')->where($tWhere . ' and week like \'%' . $tWeek . '%\'')->fList();
         foreach ($tDatas as $tRow) {
             #透析中心信息
             $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow();
             if (!count($tUARow)) {
                 continue;
             }
             $tCRow = $tCMO->field('tomorrow_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow();
             if (!count($tCRow)) {
                 continue;
             }
             $tTitle = '透析提醒';
             $tTimecodestr = '上午' . $tRow['time'];
             $tTpl_val = '#timecodestr#=明日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['tomorrow_weather'];
             $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#';
             #用户信息
             $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow();
             if (!count($tURow)) {
                 continue;
             }
             $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx')));
             #设备信息
             $tSql = 'select cid,devicetoken  from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did';
             $tUDDatas = $tUDMO->query($tSql);
             $tTimecodestr = date('m月d日', $tTime + 86400) . '上午' . $tRow['time'];
             $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['tomorrow_weather'];
             foreach ($tUDDatas as $tR) {
                 $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR));
                 $tRedis->lpush('dakang_getui', $tRes);
             }
             #添加透析日期
             $tODDRow = $tODDMO->field('count(0) c')->where('uid = ' . $tRow['uid'] . ' and date = \'' . $tDate . '\'')->fRow();
             if (!empty($tODDRow['c'])) {
                 continue;
             }
             $tData = array('date' => $tDate, 'uid' => $tRow['uid'], 'time_code' => $tRow['time_code'], 'created' => $tTime);
             $tODDMO->insert($tData);
         }
     }
     exit;
 }
Exemple #3
0
 public function listAction()
 {
     $p = $_REQUEST;
     $tUAMO = new UserassessmentModel();
     $tRow = $tUAMO->field('*')->where(' uid = ' . $this->tUid)->fRow();
     $tRow['medical_date_01'] = empty($tRow['medical_date_01']) ? '0000-00' : substr($tRow['medical_date_01'], 0, strlen($tRow['medical_date_01']) - 3);
     $tRow['medical_date_02'] = empty($tRow['medical_date_02']) ? '0000-00' : substr($tRow['medical_date_02'], 0, strlen($tRow['medical_date_02']) - 3);
     $tRow['medical_date_03'] = empty($tRow['medical_date_03']) ? '0000-00' : substr($tRow['medical_date_03'], 0, strlen($tRow['medical_date_03']) - 3);
     $tRow['medical_date_04'] = empty($tRow['medical_date_04']) ? '0000-00' : substr($tRow['medical_date_04'], 0, strlen($tRow['medical_date_04']) - 3);
     $tCDMO = new CenterModel();
     $tCRow = $tCDMO->field('provinces,cities,name')->where(' id = ' . $tRow['medical_id'])->fRow();
     $tRow['provinces'] = empty($tCRow['provinces']) ? '' : $tCRow['provinces'];
     $tRow['cities'] = empty($tCRow['cities']) ? '' : $tCRow['cities'];
     $tRow['medical_addr'] = empty($tCRow['name']) ? '' : $tCRow['name'];
     $tODTMO = new OrdinarydialysistimeModel();
     $tODTRow = $tODTMO->field('time,week')->where(' uid =' . $this->tUid)->fRow();
     $tRow['time'] = empty($tODTRow['time']) ? '' : $tODTRow['time'];
     $tRow['week'] = empty($tODTRow['week']) ? '' : $tODTRow['week'];
     Tool_Fnc::ajaxMsg('', 1, $tRow);
 }
Exemple #4
0
 public function infoAction()
 {
     $tMO = new UserModel();
     $tRow = $tMO->field('headimg,phone,sex,dry_weight,date_of_birth')->where('id = ' . $this->tUid)->fRow();
     if (!count($tRow)) {
         Tool_Fnc::ajaxMsg('获取信息失败');
     }
     $tUAMO = new UserassessmentModel();
     $tARow = $tUAMO->field('name,medical_id')->where(' uid = ' . $this->tUid)->fRow();
     $tCMO = new CenterModel();
     $tCRow = $tCMO->field('name')->where(' id = ' . $tARow['medical_id'])->fRow();
     $tODTMO = new OrdinarydialysistimeModel();
     $tODTRow = $tODTMO->field('time,week,time_code')->where(' uid = ' . $this->tUid)->fRow();
     unset($tARow['medical_id']);
     $tRow = array_merge($tRow, $tARow);
     if (!empty($tRow['headimg']) && !Tool_Validate::url($tRow['headimg'])) {
         $tRow['headimg'] = Yaf_Registry::get("config")->web->url->img . $tRow['headimg'];
     }
     Tool_Fnc::ajaxMsg('', 1, array_merge($tRow, array('medical_addr' => $tCRow['name'], 'assess_time' => $tODTRow)));
 }