public static function fetchConsultDoctorsByUserIDRole($id, $role) { if (!is_numeric($id) || !is_numeric($role)) { return array(); } $sql = "SELECT DISTINCT to_user,to_role FROM yy_consult_dialog WHERE from_user={$id} AND from_role={$role} AND to_role=2 AND status=1"; $data = self::getDb()->query($sql)->fetchAll(); $results = array(); if (count($data) > 0) { foreach ($data as $da) { $result = array('id' => $da['to_user']); $na = Yy_Utils::getNameAvatar($da['to_user'], 2); $result['name'] = $na['name']; $result['avatar'] = $na['avatar']; array_push($results, $result); } } return $results; }
public function dhistoryAction() { $id = $this->_getParam('id'); //userid $role = $this->_getParam('role'); //get from doctorAction if ($this->_auth->userid && $this->_auth->role == 2) { $una = Yy_Utils::getNameAvatar($id, $role); $out['uid'] = $id; $out['uname'] = $una['name']; $out['uavatar'] = $una['avatar']; $dna = Yy_Utils::getNameAvatar($this->_auth->userid, 2); $out['did'] = $this->_auth->userid; $out['dname'] = $dna['name']; $out['davatar'] = $dna['avatar']; $historys = Application_Model_M_ConsultDialog::fetchHistoryByUserIdRoleAndDoctorId($id, $role, $this->_auth->userid); if (count($historys) > 0) { $historys = array_reverse($historys); $out['errno'] = '0'; $results = array(); foreach ($historys as $history) { $result = array('id' => $history->getFrom_user(), 'msg' => $history->getMessage(), 'time' => $history->getCtime()); array_push($results, $result); } $out['historys'] = $results; } else { $out['errno'] = '1'; } } else { $out['errno'] = '200'; } $out['msg'] = Yy_ErrMsg_Consult::getMsg('dhistory', $out['errno']); Yy_Utils::jsonOut($out); }