PK

ADDRLIN : /home/anibklip/pcfcindia.com/24-25/
FLL :
Current File : /home/anibklip/pcfcindia.com/24-25/export_inv_2.php

<?php
include("connexion.php");

function getColumn($table, $field, $val, $col, $orderby=""){
	if($orderby!=""){
		$or=" order by ".$orderby;
	}
	$q="select $col from $table where $field='$val' $or";
	$q=mysql_query($q) or die(mysql_error());
	if($r=mysql_fetch_array($q)){
		return $r[0];
	}else{
		return false;
	}
}

$csv_output="";

$sql = "SELECT * From invoices where dtd >= '$_GET[sdt]' and dtd <= '$_GET[edt]'  order by dtd asc";
$result = mysql_query($sql) or die('error in invoiceno');
if (mysql_num_rows($result) == 0) {
	$csv_output .= "No Result found in Invoices.";
}else{
	$csv_output .= "Invoice No, Invoice Date, Amount, CGST 9%, SGST 9%, IGST 18%";
	$csv_output .= "\n";

	while ($row = mysql_fetch_array($result)) {
		$round = round($row['grandtotal'] - $row['amount']);
		
		if($row[gst_combine]){
			$igst=$row['amount']/100*18;
			$cgst="";
			$sgst="";
		}else{
			$igst="";
			$cgst=$row['amount']/100*9;
			$sgst=$row['amount']/100*9;
		}
		$csv_output .= $row['invid'].", ";
		$csv_output .= date("d-m-Y", strtotime($row['dtd'])).", ";
		$csv_output .= $row['amount'].", ";	
		$csv_output .= $cgst.", ";	
		$csv_output .= $sgst.", ";	
		//$csv_output .= $row['amount']+$row['servicetax'].", ";
		$csv_output .= $igst.", ";
		$csv_output .= "\n";
	}
}

$filename = "INV_".date("d-m-Y_H-i",time());

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");

//$csv_output=str_replace("\n","<br>",$csv_output);

print $csv_output;
?>


PK 99