<?php defined('BASEPATH') OR exit('No direct script access allowed');
/*
$i=0;
foreach( $itemlist as $items)
{
	foreach ($items as $key => $value)
	{
		if ($i++ == 0)
		{
			printf("[%010s]|", $key );
			echo "\n";
		}

		printf("[%010s]|", $value);
	}
	echo "\n";
}
*/
	// Company Address
	echo $company["compName"] . PHP_EOL;
	// Branch Name
	if (!empty($company["company"]))
	{
		echo $company["company"] . PHP_EOL;
	}

	if (!empty($company["phone"]))
	{
		echo "Ph: " . $company["phone"] . PHP_EOL;
	}

	if (!empty($company["mobile"]))
	{
		echo "Mob: " . $company["mobile"] . PHP_EOL;
	}

	if (!empty($company["email"]))
	{
		echo "@: " . $company["email"] . PHP_EOL;
	}

	if (!empty($company["gstin"]))
	{
		echo lang("GSTIN").":" . $company["gstin"] . PHP_EOL;
	}

	if (!empty($company["pan"]))
	{
		echo "Pan: " . $company["pan"] . PHP_EOL;
	}

	echo PHP_EOL;

	echo $titleText . PHP_EOL;
	echo $tNo_text . ": " . $tNo . PHP_EOL;
	echo $tDate_text . ": " . $tDate . PHP_EOL;

	echo PHP_EOL;

	if (!empty($billing))
	{
		echo "To: " . $billing["name"] . PHP_EOL;
		if (!empty($contact))
		{
			if (!empty($contact["taxNo"]))
			{
				echo lang("GSTIN"). ":" . $contact["taxNo"] . PHP_EOL;
			}
			if (!empty($contact["perTax"]))
			{
				echo "Pan: " . $contact["perTax"] . PHP_EOL;
			}
		}
		
		echo PHP_EOL;
	}

	if (!empty($shipping) && $shipping["addrType"] == "S")
	{
		echo $shipping["name"] . PHP_EOL;
		echo PHP_EOL;
	}

	echo "SubTotal: " . formatAmount($taxableAmount, $currencyCode, "-", true) . PHP_EOL;

	if ($includeDiscount && $discountTotal)
	{
		echo "less Discount " . (empty($discountPercent) ? "" : ((int)$discountPercent . "%")) . ": " . $discountTotal . PHP_EOL;
	}

	if (!empty($tax))
	{
		foreach ($tax as $key => $tax_item)
		{
			echo $tax_item['taxName'] . ' ' . round($tax_item['taxRate'], 2) . "%: ";
			echo formatAmount($tax_item['taxValue'], $currencyCode, "-", true);
			echo PHP_EOL;
		}
	}

	if($roundAmount && (float)$roundAmount)
	{
		echo "Round Off: " . $roundAmount . PHP_EOL;
	}

	if(!empty($tdsPercentage) && $tdsPercentage != 0)
	{
		echo "TDS @ " . $tdsPercentage . "%: " . $tdsAmount . PHP_EOL;
	}

	$totLessCharges = 0;
	echo "Total: " . formatAmount($totAmount + $totLessCharges, $isExport ? $expCurrencyCode : $currencyCode, "-", $isExport ? true : false) . PHP_EOL;

