<style>
.myh1{
  font-size:16px;
  font-family:Arial;
}
.myh2{
  font-size:14px;
  font-family:Arial;
  font-weight:100;
}
.td1{
  padding-left: 10px;
}
.ipt1{
font-family:Arial;
font-size:12px;
text-align:center;
}
.lsttable{
font-family:Arial;
border-collapse:collapse;
margin: 5px 5px 5px 5px ;
}
.div_desc{
margin: 10px 10px 10px 10px;
font-family:Arial;
font-style:italic;
font-size:12px;
text-align:left;
width:600px;
}
    
  .rpt_tbl{
  font-family:Arial;
  font-size:14px;
  width:700px;
    
  }
</style>
<?
$numpgbk = $_POST["npgbk"];
?>
<?
foreach($arrTea as $tteaid=>$tteaename){
?>

  <center>
<div style="page-break-after:always">
  
<table width="800px" border="0">
<tr>
  <th rowspan="2">
    <img src="img/<?= $mysys->imgPath ?>" height="50px" />
  </th>
  <th class="myh1">LAPORAN KEHADIRAN <?= strtoupper($mysys->schName)  ?></th>
</tr>
<tr>
  <th colspan="2" class="myh1">STAF : <u><?= strtoupper($tteaename) ?></u><br>
     TARIKH : <u><?= convertDateFor($datefrom) ?> ~ <?= convertDateFor($datetil) ?></u></th>
</tr>
</table>
      
<hr width="800px" />
      
<table class="lsttable" width="800px"  border="1">
  <tr>
	<th>TARIKH</th>
	<th>MASUK</th>
	<th>KELUAR</th>
	<th>CATATAN</th>
  </tr>
  <?
  $i=1;
  $tdate = $datefrom;
  while($tdate<=$datetil){
  
    $strHol = "";
      
    if( count(getHoliday($tdate))>0 ){
      $strHol = "[" . implode(",",getHoliday($tdate)) . "]";
    }
  
    $strRemark = "";
  
    if( $arrPunchintime[$tdate][$tteaid] == "" ){
	  $arrPunchintime[$tdate][$tteaid] = "-";
	}
    if( $arrPunchouttime[$tdate][$tteaid] == "" ){
	  $arrPunchouttime[$tdate][$tteaid] = "-";
	}
    if( $arrRemark[$tdate][$tteaid] == "" ){
	  $arrRemark[$tdate][$tteaid] = "&nbsp;";
	}
	
    if( $arrComlate[$tdate][$tteaid]=="" ){
	  $arrComlate[$tdate][$tteaid]="00:00:00";
	}
    if( $arrLevearly[$tdate][$tteaid]=="" ){
	  $arrLevearly[$tdate][$tteaid]="00:00:00";
	}

    $lateDesc="";
    unset($arrLateDesc);

	if( $arrComlate[$tdate][$tteaid]=="00:00:00" ){
	  $acolors1 = "";
	  $acolore1 = "";
	  $lateDesc = $lateDesc . "";
	}else{
	  if($highlight=="1"){
	    $acolors1 = " ( ";
	    $acolore1 = " ) ";
	  }else{
	    $acolors1 = " <font color='red'> ";
	    $acolore1 = " </font> ";
	  }
	  $arrLateDesc[] = "Lewat = " . $arrComlate[$tdate][$tteaid];
	}
	
	if( $arrLevearly[$tdate][$tteaid]=="00:00:00" ){
	  $acolors2 = "";
	  $acolore2 = "";
	  $lateDesc = $lateDesc . "";
	}else{
	  if($highlight=="1"){
	    $acolors2 = " ( ";
	    $acolore2 = " ) ";
	  }else{
	    $acolors2 = " <font color='red'> ";
	    $acolore2 = " </font> ";
	  }
	  $arrLateDesc[] = "Pulang Awal = " . $arrLevearly[$tdate][$tteaid];
	}

    if( count($arrLateDesc)>0 ){
        $strLateDesc = implode("; ",$arrLateDesc) . "<br>";
    }else{
        $strLateDesc = "";
    }
      
//    if($arrMessage[$tdate][$tteaid]!=""){
//	  $strRemark = $arrMessage[$tdate][$tteaid]."; ".$arrRemark[$tdate][$tteaid];
//	}else{
//	  $strRemark = $arrRemark[$tdate][$tteaid];
//	}
      
      
    if($arrMessage[$tdate][$tteaid]!=""){
	  if($arrRemarkEvent[$tdate][$tteaid]!=""){
	    $strRemark = $arrMessage[$tdate][$tteaid]."; [".$arrEvent[ $arrRemarkEvent[$tdate][$tteaid] ]."] ".$arrRemark[$tdate][$tteaid];
	  }else{
        $strRemark = $arrMessage[$tdate][$tteaid];
	  }
	}else{
	  if($arrRemarkEvent[$tdate][$tteaid]!=""){
	    $strRemark = $arrEvent[ $arrRemarkEvent[$tdate][$tteaid] ];
        if($arrRemark[$tdate][$tteaid]!=="&nbsp;"){
            $strRemark .= " - " . $arrRemark[$tdate][$tteaid];
        }
	  }else{
	    $strRemark = "&nbsp;";
	  }
	}
      

  ?>
  <?
    $arrtemp = explode("-",$tdate);
	$tmktime = mktime(0, 0, 0, $arrtemp[1], $arrtemp[2], $arrtemp[0]);
    $weekdate = date("N",$tmktime);
  ?>
  <tr <?= $tborder ?>>
    <td width="150px" style="padding-left: 5px"><?= date("d-m-Y", $tmktime) ?> <span style="font-style:italic; font-size:12px"><?= $arrMinggu[$weekdate] ?></span></td>
	<td align="center" width="95px"><?= $acolors1 . $arrPunchintime[$tdate][$tteaid] . $acolore1 ?></td>
	<td align="center" width="95px"><?= $acolors2 . $arrPunchouttime[$tdate][$tteaid] . $acolore2 ?></td>
	<td style="font-size:11px; vertical-align: middle; padding-left: 5px"><?= $strLateDesc ?><?= $strRemark ?><?= $strHol ?></td>
  </tr>
  <?
    if( ($i%$numpgbk)==0 ){
	?>
  </table>
  </div>
	
	  <?
	  if( $tdate<$datetil ){
	  ?>
  <div style="page-break-after:always">
  <table border="1" style="font-family:Arial; width:700px">
    <tr>
	  <th colspan="4" style="height:30px">
	    <?= $mysys->schName ?> Laporan Kehadiran - <?= $tteaename ?>
	  </th>
	</tr>
	<tr>
	  <th>TARIKH</th>
	  <th>WAKTU MASUK</th>
	  <th>WAKTU KELUAR</th>
	  <th>CATATAN</th>
	</tr>
	  <?
	  }
	  ?>
	
	<?
	}
  ?>
  
  <?
    $tdate=add_date($tdate,1);
	$i++;
  }
  ?>
  </table>
  </div>
  </center>

<?
}
?>