<link href="/min?f=/css/destination.css" rel="stylesheet">
<style type="text/css">
#iframepage{min-height: 1024px;}
.footer{background: #f0f0f0;}
</style>
<div class="container-fluid">
	<div class="row">

		<div class="col-sm-4">
			<div class="row">
				<form method="post" action="<?php echo site_url('apps/paypal/index/search'); ?>">
				<div class="input-group">
			      <input type="text" name="search_key" value="<?php echo isset($search_key)?$search_key:''; ?>" class="form-control" placeholder="订单号、客人邮箱" style="height: 33px;-webkit-box-shadow: inset 0 0px 0px rgba(0,0,0,0.075);box-shadow: inset 0 0px 0px rgba(0,0,0,0.075);border:none;border-bottom:1px solid #ddd;">
			      <span class="input-group-btn">
			        <button class="btn btn-default" type="submit" style="border:none;border-bottom:1px solid #ddd;"><span class="glyphicon glyphicon-search"></span></button>
			      </span>
			    </div>
			    </form>
			</div>
			
			<div class="col-xs-24 btn-lg"></div>
			<ul class="list-unstyled hidden-xs">
			<li><a href="<?php echo site_url('apps/paypal/index'); ?>">全部收款邮件</a></li>
			<li class="btn-sm"></li>
			<?php if(!empty($userdata['OPI_Email']) && !empty($userdata['OPI_FirstName'])){ ?>
			<li><a href="<?php echo site_url('apps/paypal/index/my_paypal'); ?>">我的收款邮件</a></li>
			<li class="btn-sm"></li>
			<?php } ?>
			<li><a href="<?php echo site_url('apps/paypal/index/get_transactions_list'); ?>">更新paypal纪录</a></li>
			<li class="btn-sm"></li>
			<li><a href="<?php echo site_url('apps/paypal/index/get_transactions_detail/1'); ?>">更新邮件列表</a></li>
			<li class="btn-sm"></li>
			
			<li><a href="<?php echo site_url('apps/paypal/index/unmatch/BIZ');?>">商务订单不匹配列表</a></li>
			<li class="btn-sm"></li>
			
			<li><a href="<?php echo site_url('apps/paypal/index/unmatch/tradition');?>">传统订单不匹配列表</a></li>
			<li class="btn-sm"></li>
			<li><a href="<?php echo site_url('apps/paypal/index/error_paypal'); ?>">错误收款邮件信息</a></li>
                        <li class="btn-sm"></li>
                        <li><a href="http://share.chtcdn.com/info.php/sendmail/send_mail" target="_blank">发送邮件</a></li>
			<li class="btn-lg"></li>
			<?php $currentmonth=date('Y-m-01 00:00:00',time()); ?>
	     	<?php for ($i=0; $i < 10; $i++) { $currentday=strtotime("$currentmonth -$i month"); ?>
	     		<li>
	     			<a href="javascript:void(0);" onclick="$('.days_box').addClass('hidden');$('#days_<?php echo date('Ym',$currentday);?>').removeClass('hidden');"><?php echo date('Y年m月',$currentday);?></a>
	     			<ul id="days_<?php echo date('Ym',$currentday);?>" class="days_box <?php echo $current_m==date('Ym',$currentday)?'':'hidden'; ?>">
	     				<?php $days=cal_days_in_month(CAL_GREGORIAN,date('m',$currentday),date('Y',$currentday)); ?>
	     				<?php for ($j=1; $j <=$days ; $j++) { ?> 
	     					<?php  if(date('Ym',$currentday)==date('Ym') && $j>date('j')) break; ?>
	     					<li><a style="<?php echo $current_d==date('Ym'.$j,$currentday)?'color:#000;':''; ?>" href="<?php echo site_url('apps/paypal/index/index/'.date('Y-m-'.$j,$currentday)); ?>"><?php echo date('Y.m.'.$j,$currentday); ?></a></li>
	     				<?php } ?>
	     			</ul>
	     		</li>
	     	<?php } ?>
	     	</ul>
		</div>

		<div class="col-sm-20"style="min-height:1024px;border-left:1px solid #ddd;">
		 <?php if(!isset($fg)){?>
		  <?php if(!isset($detail_tpl)){ ?>
		   <ul class="row mail_list hidden-xs">
		      <a href="javascript:void(0);" style="cursor:default;color:#000;">
		      <li class="col-sm-5"><strong>客人邮箱</strong></li>
		      <li class="col-sm-7 <?php if(!isset($error)) {echo 'col-md-9';}else{echo 'col-md-6';}?>"><strong>主题</strong></li>
		      <li class="col-sm-4 <?php if(!isset($error)) {echo 'col-md-3';}else{echo 'col-md-5';}?>"><strong>外联</strong></li>
		     
		      <li class="col-sm-4 <?php if(!isset($error)) {echo 'col-md-3';}else{echo 'col-md-4';}?> nopadding-L"><strong> <?php 
		      		if(isset($error)){echo '错误状态';}?>
		     </strong></li>
		      <li class="col-sm-4 col-md-2 nopadding-L"><strong>北京时间</strong></li>		
		      </a>
		   </ul>
		   
		   <ul class="row mail_list mail_loading_box hidden">
		      <li class="col-xs-24"><img src="/css/images/loading.gif"> <small class="text-muted">正在更新收件箱</small>...</li>
		   </ul>
		   <?php
			
		   foreach ($list as $key => $mail) { 
			if(isset($error)){
		   	?>
		     <ul class="row mail_list">
		    
		      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN); ?>">
		      <li class="col-sm-5 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"><?php echo ($key+1).'.　'.$mail->M_ReplyToEmail; ?></li>
		      </a>
		      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN); ?>">
		      <li class="col-sm-7 col-md-6"><?php if(!empty($mail->pm_orderid)){ echo $mail->pm_orderid.' / '.$mail->pm_money.' '.$mail->pm_currency.' / '.$mail->pm_payer; if($mail->pm_money<0)echo '【退款】'; ?> <?php }else{  ?> 来自<?php if(!empty($mail->pm_payer)){echo $mail->pm_payer;} ?>的付款【<?php echo $mail->pm_money.' '.$mail->pm_currency; ?>】<?php } ?></li>
		      </a>
		      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN); ?>">
		      <li class="col-sm-5 col-md-4"><?php echo $mail->M_ToEmail; ?></li>
		      </a>
		      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN); ?>">
		      
		      <li class="col-sm-5 col-md-4"><?php
		      	if(empty($mail->pm_orderid) && empty($mail->M_ToEmail)){
		      		echo '<b class="text-danger">订单号和邮件地址缺失</b>';
		      	}else if(empty($mail->pm_orderid) && !empty($mail->M_ToEmail)){
		      		echo '<b class="text-danger">订单号缺失</b>';
		      	}else if(!empty($mail->pm_orderid) && empty($mail->M_ToEmail)){
		      		echo '<b class="text-danger">邮件地址缺失</b>';
		      	}else{
		      		echo '<b class="text-danger">其他信息缺失</b>';}
		      	
		     ?></li>
		      </a>
		       <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN); ?>">
		      
		     <li class="col-sm-3 col-md-4 nopadding-L hahaha"><?php echo date('Y-m-d H:i',strtotime($mail->M_AddTime)); echo $mail->M_State==1?'[已发出]':'[<span class="text-danger">未发送</span>]';?></li>
		      </a>
		   </ul>
		    <?php
		    
		   }else{
		    ?>
		   
		   <ul class="row mail_list">
		    
		      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN); ?>">
		      <li class="col-sm-5 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"><?php echo ($key+1).'.　'.$mail->M_ReplyToEmail; ?></li>
		      </a>
		      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN); ?>">
		      <li class="col-sm-7 col-md-9"><?php if(!empty($mail->pm_orderid)){ echo $mail->pm_orderid.' / '.$mail->pm_money.' '.$mail->pm_currency.' / '.$mail->pm_payer; if($mail->pm_money<0)echo '【退款】'; ?> <?php }else{  ?> 来自<?php if(!empty($mail->pm_payer)){echo $mail->pm_payer;} ?>的付款【<?php echo $mail->pm_money.' '.$mail->pm_currency; ?>】<?php } ?></li>
		      </a>
		      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN); ?>">
		      <li class="col-sm-6 col-md-6"><?php echo $mail->M_ToEmail; ?></li>
		      </a>
		      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN); ?>">
		      
		     <li class="col-sm-6 col-md-4 nopadding-L hahaha"><?php echo date('Y-m-d H:i',strtotime($mail->M_AddTime)); echo $mail->M_State==1?'[已发出]':'[<span class="text-danger">未发送</span>]';?></li>
		      </a>
		   </ul>
		   
		   
		   
		   
		   <?php }} ?>

		    <div class="col-xs-24">
		      <nav>
		        <ul class="pager pull-left">
		            <?php echo isset($pageinfo['htmls'])?$pageinfo['htmls']:''; ?>
		        </ul>
		      </nav>
		    </div>
  		  <?php }else{ ?>
  		  <div class="col-sm-17 col-xs-24">
  		  	<iframe id="iframepage" src="<?php echo site_url('apps/paypal/index/detail/'.$mail->M_SN.'/1'); ?>" width="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" onLoad="init_iframe_height();"></iframe>
  		  </div>
  		  <div class="col-xs-24 col-sm-7">
  		  	<div class="col-xs-24 well" style="border:none;margin-top:100px;word-break: break-word;min-height:450px;">
  		  		<h4>订单信息<small>(有可能不准确,仅供参考)</small></h4>
  		  		<legend></legend>
  		  		<?php if(!empty($orderinfo)){ ?>
  		  		<p><span>外联：</span><?php echo $orderinfo->OPI_Name; ?></p>
  		  		<p><span>外联邮箱：</span><?php echo $orderinfo->OPI_Email; ?></p>
  		  		<p><span>订单号：</span><?php echo $orderinfo->COLI_ID; ?></p>
  		  		<p><span>团号：</span><?php echo isset($orderinfo->COLI_GroupCode)?$orderinfo->COLI_GroupCode:''; ?></p>
  		  		<p><span>订单提交日期：</span><?php echo $orderinfo->COLI_ApplyDate; ?></p>
  		  		<p><span>订单备注：</span><?php echo $orderinfo->COLI_Memo; ?></p>
  		  		<p><span>其他：</span><?php echo $orderinfo->COLI_OrderDetailText; ?></p>
  		  		<?php }else{ ?>
  		  		<p>查找订单信息失败！</p>
  		  		<?php } ?>
  		  	</div>
  		  	
  		  </div>
  		  <?php } }else{?>
  		  	<ul class="row mail_list hidden-xs">
  		  	<a href="javascript:void(0);" style="cursor:default;color:#000;">
  		  	<li class="col-sm-5"><strong>订单号</strong></li>
  		  	<li class="col-sm-6 col-md-6"><strong>外联邮箱</strong></li>
  		  	<li class="col-sm-4 col-md-6"><strong>发送人邮箱</strong></li>
  		  	<li class="col-sm-5 col-md-6"><strong>发送时间</strong></li>
  		  	
  		  </a>
  		  </ul>
  		   <?php 
  		   		foreach ($list2 as $key=>$value){
  		   ?>
			 <ul class="row mail_list">
			      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$value->M_SN); ?>">
			      <li class="col-sm-4 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"><?php echo ($key+1).'.　'.$value->COLI_ID; ?></li>
			      </a>
			      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$value->M_SN); ?>">
			      <li class="col-sm-6 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"><?php echo $value->OPI_Email; ?></li>
			      </a>
			      <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$value->M_SN); ?>">
			      <li class="col-sm-6 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"><?php echo $value->M_ToEmail; ?></li>
			      </a>
			       <a class="seen" href="<?php echo site_url('apps/paypal/index/detail/'.$value->M_SN); ?>">
			      <li class="col-sm-5 nopadding-L" style="overflow:hidden;word-break: break-all;height: 25px;"><?php echo $value->pm_create_date; ?></li>
			      </a>
		   </ul>
		     
  		  <?php }}?>
		</div>

	</div>
</div>

<script type="text/javascript">
function init_iframe_height() {
  var ifm= document.getElementById("iframepage");   
  var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;   
  if(ifm != null && subWeb != null) {
     ifm.height = subWeb.body.scrollHeight;
     ifm.width = subWeb.body.scrollWidth;
  } 
}
</script>