</thead>
  <tbody>
    <tr class="<?php 
echo $class;
?>
"> 
      <td width="6%" align="center"><font color="#0FA40B"><strong><?php 
echo $kdgiat;
?>
</strong></font></td>
      <td colspan="3" align="left"><font color="#0FA40B"><strong><?php 
echo nm_giat($kdgiat);
?>
</strong></font></td>
      <td width="12%" align="right"><font color="#0FA40B"><strong><?php 
echo number_format(real_giat_spm($th, $kdsatker, $kdgiat), "0", ",", ".");
?>
</strong></font></td>
    </tr>
    <?php 
if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $table_1 . "'")) == 1 and mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $table_2 . "'")) == 1) {
    $sql = "select sum(totnilmak) as real_giat from {$table_1} WHERE thang='{$th}' AND kdsatker='{$kdsatker}' and kdgiat='{$kdgiat}' group by kdgiat";
    $aGiat = mysql_query($sql);
    $Giat = mysql_fetch_array($aGiat);
    $sql = "select kdoutput, sum(totnilmak) as real_output from {$table_1} WHERE thang='{$th}' and kdsatker='{$kdsatker}' and kdgiat='{$kdgiat}' group by kdoutput order by kdoutput";
    $aOutput = mysql_query($sql);
    while ($Output = mysql_fetch_array($aOutput)) {
        ?>
    <tr class="<?php 
        echo $class;
        ?>
</strong></td>
      <td width="7%" align="center"><strong><?php 
        echo number_format(($real_satker_spm - $real_satker_sp2d) / $col[1][$k] * 100, "2", ",", ".");
        ?>
</strong></td>
      <td width="7%" align="center"><a href="index.php?p=631&kdsatker=<?php 
        echo $col[0][$k];
        ?>
" title="Grafik Realisasi"><img src="css/images/chart.jpg" border="0" width="16" height="16"></a></td>
    </tr>
    <?php 
        $kdsatker = $col[0][$k];
        $sql = "select KDGIAT, sum(JUMLAH) as pagu_giat from d_item WHERE KDDEPT = '{$kddept}' AND KDUNIT = '{$kdunit}' AND THANG = '{$th}' AND KDSATKER = '{$kdsatker}' GROUP BY KDGIAT ORDER BY KDGIAT";
        $aGiat = mysql_query($sql);
        while ($Giat = mysql_fetch_array($aGiat)) {
            $real_giat_spm = real_giat_spm($th, $kdsatker, $Giat['KDGIAT']);
            $real_giat_sp2d = real_giat_sp2d($th, $kdsatker, $Giat['KDGIAT']);
            ?>
    <tr class="<?php 
            echo $class;
            ?>
"> 
      <td align="center" valign="top"><font color="#0000FF"><?php 
            echo $Giat['KDGIAT'];
            ?>
</font></td>
      <td align="left" valign="top"><font color="#0000FF"><?php 
            echo nm_giat($Giat['KDGIAT']);
            ?>
</font></td>
      <td align="right" valign="top"><font color="#0000FF"><?php