<?php
$autoWid = 100;
$autoWid -= 18;
$autoWid -= count($taxTypes) * 8;
$autoWid -= count($taxTypes) * 10;
?>
<table cellpadding="0" cellspacing="0" class="hsn_table footTable vat" autosize="1" style="page-break-inside: avoid">
	<col style="width:<?php echo $autoWid; ?>%;" />
	<col style="width:18%;" /><?php
		foreach ($taxTypes as $val)
		{
			echo '<col style="width:8%" />';
			echo '<col style="width:10%" />';
		}
	?><thead>
		<tr>
			<th class="al" <?php echo (!empty($istaxsheet)) ? 'style="border-top:none;"' : ''; ?> rowspan="2"><?php echo mylang("HSN/SAC");?></th>
			<th class="ar" <?php echo (!empty($istaxsheet)) ? 'style="border-top:none;"' : ''; ?> rowspan="2"><?php echo mylang("TaxableValue"); ?></th><?php
			foreach ($taxTypes as $val)
			{
				if(!!empty($istaxsheet))
				{
					echo '<th class="ac" colspan="2" style="" >' . $val . '</th>';
				}
				else
				{
					echo '<th class="ac" colspan="2" style="border-top:none;" >' . $val . '</th>';
				}
			}
		?></tr>
		<tr><?php
			foreach ($taxTypes as $val)
			{
				echo '<th class="ar">'.mylang("TaxRate").'</th>';
				echo '<th class="ar">'.mylang("Amount").'</th>';
			}
		?></tr>
	</thead>
	<tbody><?php
		$totalTaxable = 0;
		$taxTotal = array();

		foreach ($hsnBreakup as $key => $val)
		{
			echo '<tr>';
			if (substr($key,0,4) == "NON_")
			{
				$key = "";// '<small class="fltrt">' . $val["taxName"] . '</small>';
			}

			$key .= '<small class="fltrt"></small>';

			echo '<td>' . $key . '</td>';
			echo '<td class="ar">' . formatAmount($val["taxableAmount"], $currencyCode, false, true,$currFraction) . '</td>';
			$totalTaxable += $val["taxableAmount"];
			foreach($taxTypes as $type)
			{
				if (empty($taxTotal[$type]))
				{
					$taxTotal[$type] = 0;
				}

				if (!empty($val[$type]))
				{
					echo '<td class="ar"><small>' . $val[$type]["taxRate"]  . '</small></td>';
					echo '<td class="ar">' . formatAmount($val[$type]["taxValue"], $currencyCode, false, true,$currFraction) . '</td>';

					$taxTotal[$type] += $val[$type]["taxValue"];
				}
				else
				{
					echo '<td></td><td></td>';
				}
			}
			echo '</tr>';
		}

		echo '<tr><td class="ar"><b>Total</b></td><td class="ar"><b>' . formatAmount($totalTaxable, $currencyCode, false, true,$currFraction) . '</b></td>';
		foreach($taxTypes as $type)
		{
			echo '<td colspan="2" class="ar"><b>' . formatAmount($taxTotal[$type], $currencyCode, false, true,$currFraction) . '</b></td>';
		}
		echo '</tr>';
	?></tbody>
</table>
