<?
viewPlugins("bootstrap");
viewLoad("public/header_person");
?>
<style>
#header {
    background-color: #fafafa;
    padding: 0;
    position: fixed;
    top: 0;
    width: 100%;
    text-align: center;
    font-size:5rem;color:#2BA1C7
}
#content {
    margin-top:120px; /* 考虑到固定在上面的 header 高度 */
    padding-left: 0;
    padding-right: 0;
}
</style>
<?
    $tableWidth = count($targets) * 7 + 6;
    $wrapperWidth = $tableWidth;
    if($tableWidth<50){
        $tableWidth = 50;
        $wrapperWidth = 40;
    }
    $tableWidth .= 'em';
    $wrapperWidth .= 'em';
    
?>
<style>
/* -------------------------------- 
Modules - reusable parts of our design

-------------------------------- */
#cd-table .cd-unchecked span, #cd-table .cd-checked span {
  display: block;
  overflow: hidden;
  text-indent: 100%;
  white-space: nowrap;
}

/* -------------------------------- 

Main components 

-------------------------------- */
#cd-table {
  position: relative;
  width: 100%;
  max-width: <?=$tableWidth?>;
  font-size: 12px;
  /* you may remove this border in case of dark backgrounds if it's annoying */
  border-right: 1px solid #e6e7f1;
}
#cd-table::after {
  /* clearfix */
  content: '';
  display: table;
  clear: both;
}
#cd-table::before {
  /* White color gradient on the right */
  content: '';
  position: absolute;
  top: 0;
  right: -1px;
  height: 100%;
  width: 35px;
  background: -webkit-linear-gradient( right , white 10%, rgba(255, 255, 255, 0));
  background: linear-gradient(to left, white 10%, rgba(255, 255, 255, 0));
  z-index: 5;
  pointer-events: none;
}
.no-cssgradients #cd-table::before {
  /* remove the gradient using modernizr if css gradients are not supported */
  display: none;
}
#cd-table.table-end::before {
  /* the gradient disappears when user is at the end of the table */
  display: none;
}
#cd-table .cd-table-container {
  position: relative;
  width: 100%;
  overflow-x: auto;
  /* smooth scrolling on touch devices */
  -webkit-overflow-scrolling: touch;
}
#cd-table .cd-table-wrapper {
  width: <?=$wrapperWidth?>;
  padding-left: 5.2rem; /*左侧*/
}
#cd-table .cd-table-column {
  width: 150px;
  float: left;
  border: 1px solid #e6e7f1;
  margin-left: -1px;
}
#cd-table .cd-table-column:last-child {
  border-right: none;
}
#cd-table h2, #cd-table ul > li {
  position: relative;
  text-align: left;
  padding: 0 0 0 0.2rem;
  border-bottom: 1px solid #e6e7f1;
  height: 32px;
  line-height: 32px;
  background-color: white;
}
#cd-table h2 {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: bold;
  color: #606272;
}
#cd-table ul > li {
  color: #787a8d;
}
#cd-table ul > li:nth-child(odd) {
  background-color: #f6f7fa;
}
#cd-table ul > li:last-child {
  border-bottom: none;
}
#cd-table .cd-unchecked span, #cd-table .cd-checked span {
  position: absolute;
  width: 16px;
  height: 16px;
  background-image: url("../img/yes-no.svg");
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 32px 16px;
  left: 50%;
  top: 50%;
  bottom: auto;
  right: auto;
  -webkit-transform: translateX(-50%) translateY(-50%);
  -moz-transform: translateX(-50%) translateY(-50%);
  -ms-transform: translateX(-50%) translateY(-50%);
  -o-transform: translateX(-50%) translateY(-50%);
  transform: translateX(-50%) translateY(-50%);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
#cd-table .cd-unchecked span {
  background-position: -16px 0;
}
#cd-table .cd-select {
  display: block;
  height: 100%;
  width: 100%;
  font-weight: bold;
}
#cd-table header.cd-table-column {
  position: absolute;
  width: 120px;
  height: 100%;
  left: 0;
  top: 0;
  z-index: 10;
  background: rgba(121, 130, 153, 0.95);
  margin-left: 0;
  border-color: #6b758d;
  box-shadow: 2px 0 0 rgba(0, 0, 0, 0.1);
  pointer-events: none;
}
#cd-table header.cd-table-column h2, #cd-table header.cd-table-column li {
  background-color: transparent;
  text-align: left;
  color: #edeef1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  border-bottom-color: #6b758d;
}
#cd-table header.cd-table-column h2 {
  color: #edeef1;
}
#cd-table header.cd-table-column li:nth-child(odd) {
  background-color: rgba(107, 117, 141, 0.95);
}
#cd-table header.cd-table-column li:last-child {
  border-bottom: 1px solid #6b758d;
}
#cd-table .cd-scroll-right {
  /* small right arrow that indicates it's possible to scroll right */
  display: block;
  width: 16px;
  height: 16px;
  position: absolute;
  right: 0;
  top: 50%;
  margin-top: -8px;
  background: url("../img/small-arrow.svg") no-repeat center center;
  z-index: 6;
  -webkit-animation: cd-scroll-right 1.5s infinite;
  -moz-animation: cd-scroll-right 1.5s infinite;
  animation: cd-scroll-right 1.5s infinite;
}
@media only screen and (min-width: 870px) {
  #cd-table {
    border-right: none;
  }
  #cd-table::before {
    display: none;
  }
  #cd-table .cd-table-wrapper {
    width: 100%;
  }
  #cd-table .cd-table-column {
    width: 20%;
    float: left;
  }
  #cd-table .cd-table-column:last-child {
    border-right: 1px solid #e6e7f1;
  }
  #cd-table header.cd-table-column {
    width: 16.66667%;
    float: left;
    background: #798299;
    box-shadow: none;
    pointer-events: auto;
  }
  #cd-table .cd-scroll-right {
    display: none;
  }
}
@media only screen and (min-width: 1170px) {
  #cd-table {
    margin: 0.2em auto;
  }
}

@-webkit-keyframes cd-scroll-right {
  0%, 100% {
    -webkit-transform: translateX(0);
  }

  50% {
    -webkit-transform: translateX(3px);
  }
}
@-moz-keyframes cd-scroll-right {
  0%, 100% {
    -moz-transform: translateX(0);
  }

  50% {
    -moz-transform: translateX(3px);
  }
}
@keyframes cd-scroll-right {
  0%, 100% {
    -webkit-transform: translateX(0);
    -moz-transform: translateX(0);
    -ms-transform: translateX(0);
    -o-transform: translateX(0);
    transform: translateX(0);
  }

  50% {
    -webkit-transform: translateX(3px);
    -moz-transform: translateX(3px);
    -ms-transform: translateX(3px);
    -o-transform: translateX(3px);
    transform: translateX(3px);
  }
}
#cd-table ul > li.li-night:nth-child(odd){background-color:rgba(107, 117, 141, 0.25);color:#333}
#cd-table ul > li.li-night{background-color:rgba(121, 130, 153, 0.20);color:#333}

#cd-table h2{
overflow: hidden;
/* white-space: nowrap; */
height: 50px;
line-height: 20px;
padding-top: 0.2rem;
vertical-align: middle;
}

#cd-table ul > li{
    font-size:0.8rem;
} 
#cd-table ul > li.err{
    /*background:#FCF3F2;*/
} 
li.err i{color:#D53F3E;font-size:0.85rem;} 

#cd-table ul > li.crefe{
    color: #ccc;
    overflow: hidden;
    white-space: nowrap;
} 
</style>
<div id="header"><i class="fa fa-vcard-o"></i></div>
<div id="content">
<?
function getTdWidth($str){
    $len = strlen($str);
    $width = '7em';
    if($len<=4){
        $width = '5em';
    }else if($len<=6){
        $width = '5em';
    }else if($len<=12){
        $width = '5em';
    }else if($len<=15){
        $width = '6em';
    }else if($len<=18){
        $width = '7em';
    }
    return $width;
}
?>
<section id="cd-table">
	<header class="cd-table-column" style="width:5rem">
		<h2></h2>
		<ul>
		    <li>参考</li>
		    <? foreach($targets as $cid=>$target):?>
    		    <? foreach($rows[$cid] as $k=>$row):?>
    			<li><span><?=$row['ddate']?></span></li>
    			<? endforeach;?>
            <? 
                break;
                endforeach;
            ?>
		</ul>
	</header>

	<div class="cd-table-container">
		<div class="cd-table-wrapper">
		    <? foreach($targets as $cid=>$target):?>
    			<div class="cd-table-column" style="width:<?=getTdWidth($target['csmall'])?>">
    				<h2><a href="<?=uUrl($USERID,'dataRecordLine','cid='.$cid)?>"><?=$target['csmall']?></a></h2>
    				<ul>
    				    <li class="crefe"><?=$target['crefe']?></li>
            		    <? foreach($rows[$cid] as $k=>$row):?>
            		        <?if($row['err']!=0):?>
            			    <li class="err"><i class="fa fa-long-arrow-<?=$row['err']==-1 ? 'down' : 'up'?>"></i> <?=$row['dvalue']?></li>
            			    <?else:?>
            			    <li><?=$row['dvalue']?></li>
            			    <?endif;?>
            			<? endforeach;?>
    				</ul>
    			</div> <!-- cd-table-column -->
            <? endforeach;?>

		</div> <!-- cd-table-wrapper -->
	</div> <!-- cd-table-container -->

	<em class="cd-scroll-right"></em>
</section> <!-- cd-table -->
</div>
<? viewLoad("public/footer_person") ?>