<?php
include "../../include/config.php";
include "../../function/inc_function.php";
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="data_at_detail_'.get_datetime().'.xls"');
header('Cache-Control: max-age=0');

$py_tipe	 	= isset($_REQUEST['py_tipe']) ? $_REQUEST['py_tipe'] : '';
$pyd_tanggal	= isset($_REQUEST['pyd_tanggal']) ? $_REQUEST['pyd_tanggal'] : $date;
 if($py_tipe=="0"){
	$search    = "";
 }else{
	$search    = "id='$py_tipe' AND";
 }

$sqlShow 	= mysql_query("SELECT prof_name FROM profil");
$dataShow 	= mysql_fetch_array($sqlShow);

?>
<table width="100%" border="0">
    <tr>
  		<td colspan="5">DATA AKTIVA TETAP (PENYUSUTAN DETAIL)</td>
    </tr>
    <tr>
  		<td colspan="5"><?=strtoupper($dataShow['prof_name']);?></td>
    </tr>
    <tr>
  		<td colspan="5">&nbsp;</td>
    </tr>
</table>	
<table border="1" cellpadding="0" cellspacing="0">
  <tr>
	<th>No</th>
	<th>Tanggal</th>
	<th>Nama Barang</th>
	<th>Satuan</th>
	<th>Nilai</th>	
  </tr>
  <?php
  	$gtnilai=0;
	$qh=mysql_query("SELECT * FROM penyusutan WHERE py_status<>100 ORDER BY id ASC");
	while($dh=mysql_fetch_array($qh)){
	?> 
    <tr bgcolor="#FFFFCC">
        <td colspan="5">Nama Barang :<?=$dh['py_nmbarang'];?></td>
    </tr>
    <?php
	$no=1;$tnilai=0;
	$qd=mysql_query("SELECT pyd_tanggal, pyd_nilai FROM penyusutan_detail WHERE pyd_hid='$dh[id]' AND pyd_status=10 ORDER BY pyd_tanggal ASC");
	while($dd=mysql_fetch_array($qd)){	
		$tnilai = $tnilai+$dd['pyd_nilai'];		
	?>
	 <tr onmouseover="setTrColor(this, '#FF9900');">
		<td align="center"><?=$no;?>.</td>
		<td align="center"><?=$dd['pyd_tanggal'];?></td>
		<td align="left"><?=$dh['py_nmbarang'];?></td>
        <td align="center"><?=$dh['py_stbarang'];?></td>
        <td align="right"><?=number_format($dd['pyd_nilai'],2,'.','');?></td>
	  </tr>	  
  <?php $no++; } 
   #} 
   ?> 
  	  <tr bgcolor="#CCFFCC">
        <td colspan="4"><b>Total</b></td>
        <td align="right"><b><?=number_format($tnilai,2,'.','');?></b></td>
      </tr>
   <?php 
   		$gtnilai= $gtnilai+$tnilai; 
	}  ?>  
   <tr bgcolor="#CCFFFF">
    <td colspan="4"><b>Grand Total</b></td>
    <td align="right"><b><?=number_format($gtnilai,2,'.','');?></b></td>
  </tr>  
</table>