<?php
InitGP(array('hid'),'G');
theme_header();
echo<<<ONEZ
<style type="text/css">
.showbox,#showbox{/*内容显示区域*/
	margin:3px 10px;
  background:#ffffff;
  height:460px;
  
	scrollbar-face-color: #F6F6f6;
	scrollbar-highlight-color: #FFFFFF;
	scrollbar-shadow-color: #F0F2DB;
	scrollbar-3dlight-color: #cccccc;
	scrollbar-arrow-color:  #666666;
	scrollbar-track-color: #FCFDF9;
	scrollbar-darkshadow-color: #cccccc; 
	overflow:hidden;
	overflow-y:auto;
}
.showbox div,#showbox div{
  margin:3px;
}
.im_to{/*“我”的名字和时间*/
  color:#008040;
  height:18px;
  line-height:18px;
}
.im_from{/*对方的名字和时间*/
  color:#0000ff;
  height:18px;
  line-height:18px;
}
.im_content{/*消息内容*/
  color:#000000;
  padding-left:10px;
}
.im_list{
  height:24px;
  padding-left:10px;
  overflow:hidden;
}
.im_fail{
  color:#999999;
}
.im_list a{
  line-height:22px;
  color:#0000cc;
  text-decoration:none;
}
.im_list a:hover{
  color:#0000cc;
  border-bottom:1px solid #0000cc;
}
.im_info{/*系统提示*/
  color:#7982c1;
  line-height:18px;
  padding-left:2px;
}
.block{
  border:1px solid #808080;
  background:#eeeeee;
  padding:10px;
  display:block;
}
</style>
ONEZ;
$ot->borderA('#content2','box2');
$T=DB()->one('history','*',"hid='$hid'");
$uid=$T['uid'];
$ot->addhead('用户'.$uid.'的对话记录');
$T=DB()->record('message','*',"hid='$hid' order by mid asc");
$html='<div class="showbox">';

$botname=option('botname');

foreach($T as $rs){
  if($rs['ifusr']){
    $html.='<div class="im_from">用户&nbsp;&nbsp;'.date('Y-m-d H:i:s',$rs['time']).'</div>';
  }else{
    $html.='<div class="im_to">'.$botname.'&nbsp;&nbsp;'.date('Y-m-d H:i:s',$rs['time']).'</div>';
  }
  $other='';
  if($rs['qid']){
    $other.='<div class="block question">匹配问题: ('.$rs['qid'].')'.DB()->select('question','content',"qid='$rs[qid]'").'</div>';
  }
  if($rs['aid']){
    $other.='<div class="block answer">匹配答案: ('.$rs['aid'].')'.DB()->select('answer','content',"aid='$rs[aid]'").'</div>';
    $html.='<div class="im_content">'.$rs['content'].$other.'</div>';
  }else{
    $html.='<div class="im_content im_fail">'.$rs['content'].'</div>';
  }
}

$html.='</div>';
$ot->addhtml($html);
$html=<<<ONEZ
<div class="act">
  <input type="button" value="显示/隐藏匹配问题" name="commit" class="formbutton" onclick="toggleQuestion()"/>
  <input type="button" value="显示/隐藏匹配答案" name="commit" class="formbutton" onclick="toggleAnswer()"/>
  <input type="button" value="返回" name="commit" class="formbutton" onclick="history.go(-1)"/>
  <br />
  <br />
</div>
ONEZ;
$ot->addhtml($html);
$ot->setview(false);
$ot->borderB(1);
$ot->flush();
echo<<<ONEZ
<script type="text/javascript">
function toggleQuestion(qid){
  $('.question').toggle();
}
function toggleAnswer(qid){
  $('.answer').toggle();
}
</script>
ONEZ;
theme_footer();
?>