<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use WGS\CLIENTXTEMPLATE\CLIENTX as CLASS_CLIENTX_INVOICE;
$addonActivate = false;
$addonPath = ROOTDIR.'/modules/addons/clientx';
if (file_exists($addonPath. '/classes/class.php')) {
	require_once $addonPath . '/classes/class.php';
	$getLicenseDetail = Capsule::table('tbladdonmodules')->where('setting', 'license_key')->where('module', 'clientx')->first();
	if (!empty($getLicenseDetail)) {
	    $CLIENTX = new CLASS_CLIENTX_INVOICE();
	    $license = $CLIENTX->wgs_clientx_get_license($getLicenseDetail->value);
	    $status = trim($license['status']);
	    if ($status == 'Active')
		$addonActivate = true;
	}
}
if (!empty($addonActivate)) {
        $getSetting = Capsule::table('mod_clientx_setting')->get();
        $settings = [];
        foreach ($getSetting as $key => $setting) {
            $settings[$setting->setting] = $setting->value;
        }
	$width = 75;
	$heights = 25;
	if(!empty($settings['invoice_logo_width'])){
	  $width = str_replace("px","",$settings['invoice_logo_width']);
	}
	if(!empty($settings['invoice_logo_height'])){
	  $heights = str_replace("px","",$settings['invoice_logo_height']);
	}
	if(!empty($settings['invoice_logo'])){
		$imageLink = $settings['invoice_logo'];
		$htmlImg = '<img src="'.$imageLink.'"  width="'.$width.'" height="'.$heights.'">';
		$pdf->writeHTML($htmlImg, true, 0, true, 0);
       }else{
		$logoFilename = 'placeholder.png';
		if (file_exists(ROOTDIR . '/assets/img/logo.png')) {
		$logoFilename = 'logo.png';
		} elseif (file_exists(ROOTDIR . '/assets/img/logo.jpg')) {
		$logoFilename = 'logo.jpg';
		}
		if($width == 75 && $heights == 25){
			$pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);
		}else{
			$imageLinkE = ROOTDIR . '/assets/img/' . $logoFilename;
			$htmlImgE = '<img src="'.$imageLinkE.'"  width="'.$width.'" height="'.$heights.'">';
			$pdf->writeHTML($htmlImgE, true, 0, true, 0);
		}
       }
}else{
	# Logo
	$logoFilename = 'placeholder.png';
	if (file_exists(ROOTDIR . '/assets/img/logo.png')) {
	$logoFilename = 'logo.png';
	} elseif (file_exists(ROOTDIR . '/assets/img/logo.jpg')) {
	$logoFilename = 'logo.jpg';
	}
	$pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75);
}
if (file_exists(dirname(dirname(__DIR__))) . '/modules/addons/gsttax/classes/class.php') {
require_once dirname(dirname(__DIR__)) . '/modules/addons/gsttax/classes/class.php';

$GST_TAX = new GST_TAX();

$gstIn = $GST_TAX->getAddonModuleSetting('gst_in');
$oldTaxNumber = $GST_TAX->getAddonModuleSetting('old_tax_number');
$sacCode = $GST_TAX->getAddonModuleSetting('hsn_code');
$count = $GST_TAX->getAddonModuleSetting();
$licensekey = $GST_TAX->getAddonModuleSetting('license_key');

$licenseStatus = $GST_TAX->license($licensekey);

if (isset($_GET['id']) && !empty($_GET['id']))
$invoiceId = $_GET['id'];
else {
$invoiceId = $id;
}

if (isset($invoiceId) && !empty($invoiceId)) {
if (!empty($invoiceId)) {
$data = Capsule::table('tblinvoices')->where('id', $invoiceId)->get();
if ((float) $data[0]->tax > 0 || (float) $data[0]->tax2 > 0) {
$currencyData = getCurrency($data[0]->userid);
$totalTaxInt = (float) $data[0]->tax + (float) $data[0]->tax2;
$totalTax = formatCurrency($totalTaxInt, $currencyData['id']);
}
$invoiceData = (array) $data[0];
$invoiceDate = date("d-m-Y", strtotime($invoiceData['date']));
if (strtotime($invoiceDate) <= strtotime('30-06-2017')) {
$taxlabel1 = $GST_TAX->getAddonModuleSetting('taxlabel1');
$taxlabel2 = $GST_TAX->getAddonModuleSetting('taxlabel2');
} else {
$getGstInvoice = $GST_TAX->GstGetGstInoive('i-' . $invoiceId);
if ($getGstInvoice['taxname'])
$taxname = $getGstInvoice['taxname'];
else {
if ($taxrate) {
$taxname = $GST_TAX->gstGetTaxName($taxrate, 1);
}
}
if ($getGstInvoice['taxname2'])
$taxname2 = $getGstInvoice['taxname2'];
else {
if ($taxrate2) {
$taxname2 = $GST_TAX->gstGetTaxName($taxrate2, 2);
}
}
}
}
}
}
$clientCountry = Capsule::table('tblclients')->where('id', $data[0]->userid)->first();
# Tax invoice Heading
if ($clientCountry->country == 'IN') {
if ($count > 0 && file_exists(dirname(dirname(__DIR__)) . '/modules/addons/gsttax/gsttax.php') && $licenseStatus['status'] == 'Active' && strtotime($invoiceDate) > strtotime('30-06-2017') && ($taxname == 'IGST' || $taxname == 'CGST' || $taxname == 'SGST' )) {
$getEnableProformaInvoicing = $GST_TAX->gstGetEnableProformaInvoicing();
if ($getEnableProformaInvoicing['value'] == '1' && $status == 'Paid') {
$pdf->SetFont($pdfFont, '', 15);
$pdf->SetXY(12, 12);
$pdf->Cell(0, 15, 'TAX INVOICE', 0, false, 'C', 0, '', 0, false, 'M', 'T');
}elseif($getEnableProformaInvoicing['value'] != '1'){
$pdf->SetFont($pdfFont, '', 15);
$pdf->SetXY(12, 12);
$pdf->Cell(0, 15, 'TAX INVOICE', 0, false, 'C', 0, '', 0, false, 'M', 'T');
}
}
}
# Invoice Status
$pdf->SetXY(0, 0);
$pdf->SetFont($pdfFont, 'B', 28);
$pdf->SetTextColor(255);
$pdf->SetLineWidth(0.75);
$pdf->StartTransform();
$pdf->Rotate(-35, 100, 225);
if ($status == 'Draft') {
$pdf->SetFillColor(200);
$pdf->SetDrawColor(140);
} elseif ($status == 'Paid') {
$pdf->SetFillColor(151, 223, 74);
$pdf->SetDrawColor(110, 192, 70);
} elseif ($status == 'Cancelled') {
$pdf->SetFillColor(200);
$pdf->SetDrawColor(140);
} elseif ($status == 'Refunded') {
$pdf->SetFillColor(131, 182, 218);
$pdf->SetDrawColor(91, 136, 182);
} elseif ($status == 'Collections') {
$pdf->SetFillColor(3, 3, 2);
$pdf->SetDrawColor(127);
} else {
$pdf->SetFillColor(223, 85, 74);
$pdf->SetDrawColor(171, 49, 43);
}
$pdf->Cell(100, 18, strtoupper(Lang::trans('invoices' . strtolower($status))), 'TB', 0, 'C', '1');
$pdf->StopTransform();
$pdf->SetTextColor(0);

# Company Details
$pdf->SetXY(15, 42);
$pdf->SetFont($pdfFont, '', 13);
foreach ($companyaddress as $addressLine) {
$pdf->Cell(180, 4, trim($addressLine), 0, 1, 'R');
$pdf->SetFont($pdfFont, '', 9);
}

$addonActive = false;
$oldVat = false;
if ($clientCountry->country == 'IN') {
if ($count > 0 && file_exists(dirname(dirname(__DIR__)) . '/modules/addons/gsttax/gsttax.php') && $licenseStatus['status'] == 'Active' && strtotime($invoiceDate) > strtotime('30-06-2017') && ($taxname == 'IGST' || $taxname == 'CGST' || $taxname == 'SGST' )) {
$addonActive = true;
$clientDetail = $GST_TAX->gstGetClientDetail($invoiceData['userid']);
if (!empty($clientDetail['currency']))
$currencyId = $clientDetail['currency'];
else {
$currenyIdQuery = Capsule::table('tblcurrencies')->where('default', '1')->first();
$currencyId = $currenyIdQuery->id;
}
$getCurrencyCode = $GST_TAX->gstGetCurrencyCode($currencyId);
if ((float) $invoiceData['credit'] > 0) {
$wgs_gst_credit = formatCurrency($invoiceData['credit'], $currencyId);
$creditDetail = $GST_TAX->wgsGstGetAppliedCreditDetail($invoiceData['id'], $invoiceData['credit'], $invoiceData['userid']);
$transsactionCount = count($transactions);
$date = date_create($creditDetail['date']);
if ($transsactionCount > 0)
$transactions[$transsactionCount] = array(
'id' => $creditDetail['id'],
'date' => date_format($date, "d/m/Y"),
'gateway' => 'Funds Applied',
'transid' => ' ',
'amount' => formatCurrency($invoiceData['credit'], $currencyId)
);
else
$transactions[0] = array(
'id' => $creditDetail['id'],
'date' => date_format($date, "d/m/Y"),
'gateway' => 'Funds Applied',
'transid' => ' ',
'amount' => formatCurrency($invoiceData['credit'], $currencyId)
);
$wgs_gst_invoicetotal = formatCurrency(($invoiceData['tax'] + $invoiceData['tax2'] + $invoiceData['subtotal']), $currencyId);
$invoiceData['total'] = ($invoiceData['tax'] + $invoiceData['tax2'] + $invoiceData['subtotal']);
}
$totalAmountInWords = $GST_TAX->GstNumberToWords($invoiceData['total']);
$sign_image = $GST_TAX->gstGetSign();

$pdf->Ln(2);
$pdf->SetFont($pdfFont, '', 10);
$pdf->Cell(180, 6, 'GSTIN' . ': ' . $gstIn, 0, 1, 'R');
$pdf->Ln(5);
/* $pdf->Ln(5);
$pdf->SetXY(15, 55);
$pdf->SetFillColor(239);
$pdf->SetFont($pdfFont, '', 10);
$pdf->Cell(65, 6, 'GSTIN' . ': ' . $gstIn, 10, 1, 'L', '1');
$pdf->Ln(10); */
} elseif ($count > 0 && file_exists(dirname(dirname(__DIR__)) . '/modules/addons/gsttax/gsttax.php') && $licenseStatus['status'] == 'Active' && strtotime($invoiceDate) <= strtotime('30-06-2017')) {
$addonActive = true;
$oldVat = true;
if ($oldTaxNumber) {
$pdf->Ln(2);
$pdf->SetFont($pdfFont, '', 10);
$pdf->Cell(180, 6, 'Service tax number' . ': ' . $oldTaxNumber, 0, 1, 'R');
$pdf->Ln(5);
/* $pdf->Ln(5);
$pdf->SetXY(15, 55);
$pdf->SetFillColor(239);
$pdf->SetFont($pdfFont, '', 10);
$pdf->Cell(60, 6, 'Service tax number' . ': ' . $oldTaxNumber, 10, 1, 'L', '1');
$pdf->Ln(10); */
} else {
$pdf->Ln(5);
}
}
}
# Header Bar

/**
* Invoice header
*
* You can optionally define a header/footer in a way that is repeated across page breaks.
* For more information, see http://docs.whmcs.com/PDF_Invoice#Header.2FFooter
*/
$pdf->SetFont($pdfFont, 'B', 15);
$pdf->SetFillColor(239);
$pdf->Cell(0, 8, $pagetitle, 0, 1, 'L', '1');
$pdf->SetFont($pdfFont, '', 10);
if($status == 'Paid')
$pdf->Cell(0, 6, Lang::trans('invoicesdatecreated') . ': ' . substr($datepaid,0,10), 0, 1, 'L', '1');
else
$pdf->Cell(0, 6, Lang::trans('invoicesdatecreated') . ': ' . $datecreated, 0, 1, 'L', '1');
$pdf->Cell(0, 6, Lang::trans('invoicesdatedue') . ': ' . $duedate, 0, 1, 'L', '1');
$pdf->Ln(5);

$startpage = $pdf->GetPage();

# Clients Details
$addressypos = $pdf->GetY();
$pdf->SetFont($pdfFont, 'B', 10);
$pdf->Cell(0, 4, Lang::trans('invoicesinvoicedto'), 0, 1);
$pdf->SetFont($pdfFont, '', 9);
if ($clientsdetails["companyname"]) {
$pdf->Cell(0, 4, $clientsdetails["companyname"], 0, 1, 'L');
$pdf->Cell(0, 4, Lang::trans('invoicesattn') . ': ' . $clientsdetails["firstname"] . ' ' . $clientsdetails["lastname"], 0, 1, 'L');
} else {
$pdf->Cell(0, 4, $clientsdetails["firstname"] . " " . $clientsdetails["lastname"], 0, 1, 'L');
}
$pdf->Cell(0, 4, $clientsdetails["address1"], 0, 1, 'L');
if ($clientsdetails["address2"]) {
$pdf->Cell(0, 4, $clientsdetails["address2"], 0, 1, 'L');
}
$pdf->Cell(0, 4, $clientsdetails["city"] . ", " . $clientsdetails["state"] . ", " . $clientsdetails["postcode"], 0, 1, 'L');
$pdf->Cell(0, 4, $clientsdetails["country"], 0, 1, 'L');
if ($customfields) {
$pdf->Ln();

$gst_in = 'no';
if (!empty($addonActive) && empty($oldVat)) {
foreach ($customfields as $customfield) {
if ($customfield['fieldname'] == 'GSTIN')
$gst_in = 'yes';
if ($customfield['fieldname'] == 'GSTIN' || $customfield['fieldname'] == 'Place of supply') {
$pdf->Cell(0, 4, $customfield['fieldname'] . ': ' . $customfield['value'], 0, 1, 'L');
} else {
$pdf->Cell(0, 4, $customfield['fieldname'] . ': ' . $customfield['value'], 0, 1, 'L');
}
if ($gst_in == 'no') {
$pdf->Cell(0, 4, 'GSTIN: Not Available', 0, 1, 'L');
}
}
} else {
foreach ($customfields as $customfield) {
if ($customfield['fieldname'] != 'GSTIN' && $customfield['fieldname'] != 'Place of supply') {
$pdf->Cell(0, 4, $customfield['fieldname'] . ': ' . $customfield['value'], 0, 1, 'L');
}
}
}
} else {
if (!empty($addonActive)) {
$pdf->Cell(0, 4, 'GSTIN: Not Available', 0, 1, 'L');
}
}
$pdf->Ln(10);

if (!empty($addonActive) && empty($oldVat) && ($taxname == 'IGST' || $taxname == 'CGST' || $taxname == 'SGST' )) {
$tblhtml = '<table width="100%" bgcolor="#ccc" cellspacing="2" cellpadding="3" border="">
<tr height="30" bgcolor="#efefef">
<td style="vertical-align: bottom; " width="35%"><strong>' . Lang::trans('invoicesdescription') . '</strong></td>
<td style="vertical-align: bottom; " width="25%"><strong>Item type</strong></td>
<td style="vertical-align: bottom; " width="25%"><strong>SAC Code</strong></td>
<!--<td style="border: 1px solid #ddd;" width="7%">' . Lang::trans('invoicescredit') . '</td>-->
<td width="15%"><strong>' . Lang::trans('quotelinetotal') . '</strong></td>
</tr> ';
foreach ($invoiceitems as $key => $item) {
$tblhtml .= '<tr height="30" bgcolor="#fff">
<td  width="35%">' . nl2br($item['description']) . '</td>
<td  width="25%">';
if (strpos(nl2br(strtolower($item['description'])), 'website design') !== false)
$tblhtml .= 'Website Design';
elseif (strpos(nl2br(strtolower($item['description'])), 'web development') !== false)
$tblhtml .= 'Web Development';
elseif (strpos(nl2br(strtolower($item['description'])), 'seo') !== false)
$tblhtml .= 'SEO';
elseif (strpos(nl2br(strtolower($item['description'])), 'amc') !== false)
$tblhtml .= 'AMC';
else
$tblhtml .= $item['type'];
$tblhtml .= '</td>
<td  width="25%">';
if (strpos(nl2br(strtolower($item['description'])), 'website design') !== false || strpos(nl2br(strtolower($item['description'])), 'web development') !== false || strpos(nl2br(strtolower($item['description'])), 'seo') !== false || strpos(nl2br(strtolower($item['description'])), 'amc') !== false)
$tblhtml .= '998314';
elseif ($item['type'] == 'Hosting')
$tblhtml .= '998315';
elseif (strpos($item['type'], 'Domain') !== false || strpos($item['type'], 'Addon') !== false)
$tblhtml .= '998319';
else
$tblhtml .= '';//'998313';
$tblhtml .= '</td>
<td  width="15%">' . $item['amount'] . '</td>
</tr>  ';
}
$tblhtml .= '<tr height="30" bgcolor="#efefef" style="font-weight:bold;">
<td align="right"  width="35%">' . Lang::trans('invoicessubtotal') . '</td>
<td colspan="2"  width="50%"></td>
<td  width="15%">' . $subtotal . '</td>
</tr>
<tr height="30" bgcolor="#fff">
<td align="right" width="35%" style="vertical-align: middle;"><strong>GST</strong></td>
<td colspan="2" width="50%">
<table width="100%" bgcolor="#ccc" cellspacing="1" cellpadding="3" border="" bordercolor="#ccc">
<tr bgcolor="#efefef">
<td width="33.3%"><strong>CGST';
if ($taxrate && $taxname == 'CGST') {
$tblhtml .= ' (' . $taxrate . '%)';
} else {
$nbsp;
}
$tblhtml .= '</strong></td>
<td width="33.3%"><strong>SGST';
if ($taxrate2 && $taxname2 == 'SGST') {
$tblhtml .= ' (' . $taxrate2 . '%)';
} else {
$nbsp;
}
$tblhtml .= '</strong></td>
<td width="33.3%"><strong>IGST';
if ($taxrate && $taxname == 'IGST') {
$tblhtml .= ' (' . $taxrate . '%)';
} else {
$nbsp;
}
$tblhtml .= '</strong></td>
</tr>
<tr bgcolor="#fff">
<td width="33.3%">';
if ($taxrate && $taxname == 'CGST') {
$tblhtml .= $tax;
} else {
$nbsp;
}
$tblhtml .= '</td>
<td width="33.3%">';
if ($taxrate2 && $taxname2 == 'SGST') {
$tblhtml .= $tax2;
} else {
$nbsp;
}
$tblhtml .= '</td>
<td width="33.3%">';
if ($taxrate && $taxname == 'IGST') {
$tblhtml .= $tax;
} else {
$nbsp;
}
$tblhtml .= '</td>
</tr>
</table>
</td>
<td width="15%" align="middle">' . $totalTax . '</td>
</tr>
<tr bgcolor="#efefef" height="30" style="font-weight:bold;">
<td align="right"  width="35%">Total Amount Incl. GST :</td>
<td width="50%" colspan="2">&nbsp;</td>';
if (isset($wgs_gst_invoicetotal) && !empty($wgs_gst_invoicetotal))
$tblhtml .= '<td width="15%" align="left">' . $wgs_gst_invoicetotal . '</td>';
else
$tblhtml .= '<td width="15%" align="left">' . $total . '</td>';
$tblhtml .= '</tr>';
if ($totalAmountInWords && $getCurrencyCode == 'INR') {
$tblhtml .= '<tr bgcolor="#efefef" height="30" style="font-weight:bold;">
<td align="right"  width="35%">Total Amount Incl. GST (in words):</td>
<td colspan="3" width="65%" align="right">' . $totalAmountInWords . '</td>
</tr>';
}
$tblhtml .='
<tr height="30" bgcolor="#efefef" style="font-weight:bold;">
<td align="right"  width="35%"><strong>Funds Applied</strong></td>
<td colspan="2"  width="50%"></td>
<td  width="15%">' . $credit . '</td>
</tr>';
$tblhtml .= '</table><br/>';
//echo $tblhtml;exit;
} else {
# Invoice Items
$tblhtml .= '<table width="100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="">
<tr height="30" bgcolor="#efefef" style="font-weight:bold;text-align:center;">
<td width="80%">' . Lang::trans('invoicesdescription') . '</td>
<td width="20%">' . Lang::trans('quotelinetotal') . '</td>
</tr>';
foreach ($invoiceitems as $item) {
$tblhtml .= '
<tr bgcolor="#fff">
<td align="left">' . nl2br($item['description']) . '<br /></td>
<td align="center">' . $item['amount'] . '</td>
</tr>';
}
$tblhtml .= '
<tr height="30" bgcolor="#efefef" style="font-weight:bold;">
<td align="right">' . Lang::trans('invoicessubtotal') . '</td>
<td align="center">' . $subtotal . '</td>
</tr>';

if ($taxname) {
$tblhtml .= '
<tr height="30" bgcolor="#efefef" style="font-weight:bold;">';
if (!empty($addonActive) && !empty($oldVat))
$tblhtml .= '<td align="right">' . $taxlabel1 . '</td>';
else
$tblhtml .= '<td align="right">' . $taxrate . '% ' . $taxname . '</td>';
$tblhtml .= '<td align="center">' . $tax . '</td>
</tr>';
}

if ($taxname2) {
$tblhtml .= '
<tr height="30" bgcolor="#efefef" style="font-weight:bold;">';
if (!empty($addonActive) && !empty($oldVat))
$tblhtml .= '<td align="right">' . $taxlabel2 . '</td>';
else
$tblhtml .= '<td align="right">' . $taxrate2 . '% ' . $taxname2 . '</td>';
$tblhtml .= '<td align="center">' . $tax2 . '</td>
</tr>';
}
$tblhtml .= '
<tr height="30" bgcolor="#efefef" style="font-weight:bold;">
<td align="right">' . Lang::trans('invoicescredit') . '</td>
<td align="center">' . $credit . '</td>
</tr>
<tr height="30" bgcolor="#efefef" style="font-weight:bold;">
<td align="right">' . Lang::trans('invoicestotal') . '</td>
<td align="center">' . $total . '</td>
</tr>
</table>';
}
$pdf->writeHTML($tblhtml, true, false, false, false, '');

$pdf->Ln(3);
if (count($transactions)) {
# Transactions
$pdf->SetFont($pdfFont, 'B', 12);
$pdf->Cell(0, 4, Lang::trans('invoicestransactions'), 0, 1);

$pdf->Ln(3);

$pdf->SetFont($pdfFont, '', 9);

$tblhtml = '<table width="100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="0">
<tr height="30" bgcolor="#efefef" style="font-weight:bold;text-align:center;">
<td width="25%">' . Lang::trans('invoicestransdate') . '</td>
<td width="25%">' . Lang::trans('invoicestransgateway') . '</td>
<td width="30%">' . Lang::trans('invoicestransid') . '</td>
<td width="20%">' . Lang::trans('invoicestransamount') . '</td>
</tr>';


foreach ($transactions AS $trans) {
$tblhtml .= '
<tr bgcolor="#fff">
<td align="center">' . $trans['date'] . '</td>
<td align="center">' . $trans['gateway'] . '</td>
<td align="center">' . $trans['transid'] . '</td>
<td align="center">' . $trans['amount'] . '</td>
</tr>';
}
$tblhtml .= '
<tr height="30" bgcolor="#efefef" style="font-weight:bold;">
<td colspan="3" align="right">' . Lang::trans('invoicesbalance') . '</td>
<td align="center">' . $balance . '</td>
</tr></table>';
}else{
$tblhtml = '<table width="100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="0">
<tr height="30" bgcolor="#efefef" style="font-weight:bold;">
<td colspan="3" align="right">' . Lang::trans('invoicesbalance') . '</td>
<td align="center">' . $balance . '</td>
</tr></table>';
}

if (!empty($sign_image)) {
$tblhtml .= '<br/><br/><table><tr bgcolor="#fff">
<td colspan="4" align="right">
<img width="80px" height="40px" src="' . $sign_image . '"><br/>Authorized Signatory
</td>
</tr></table>';
}
//echo $tblhtml;die();
$pdf->writeHTML($tblhtml, true, false, false, false, '');

# Notes
if ($notes) {
$pdf->Ln(5);
$pdf->SetFont($pdfFont, '', 8);
$pdf->MultiCell(170, 5, Lang::trans('invoicesnotes') . ': ' . $notes);
}

if ($data[0]->userid) {
$clientCountry = Capsule::table('tblclients')->where('id', $data[0]->userid)->first();
# Tax invoice Heading
if ($clientCountry->country == 'IN') {
if ($count > 0 && file_exists(dirname(dirname(__DIR__)) . '/modules/addons/gsttax/gsttax.php') && $licenseStatus['status'] == 'Active' && strtotime($invoiceDate) > strtotime('30-06-2017') && ($taxname == 'IGST' || $taxname == 'CGST' || $taxname == 'SGST' )) {
$getEnableProformaInvoicing = $GST_TAX->gstGetEnableProformaInvoicing();
if ($getEnableProformaInvoicing['value'] == '1' && $status != 'Paid') {
$pdf->SetFont($pdfFont, '', 8);
$pdf->Ln(5);
$pdf->Cell(180, 4, 'The invoice is computer generated invoice as proforma invoice and can not be used for tax purpose.', '', '', 'C');
}
}
}
}
# Generation Date
$pdf->SetFont($pdfFont, '', 8);
$pdf->Ln(5);
$pdf->Cell(180, 4, Lang::trans('invoicepdfgenerated') . ' ' . getTodaysDate(1), '', '', 'C');

/**
* Invoice footer
*/
?>
