<?php
require "commonincludefiles.php";


//error_reporting(1);
ini_set('memory_limit', '-1');
require_once 'excel_reader2.php';
echo "ok";
exit;
echo $fullpath=$_FILES['enrollment_upload']['tmp_name'];
exit;

$data = new Spreadsheet_Excel_Reader($fullpath);
$html="";
$i=0;
$n=1;
$r=1;
$more_record=0;	
$total=count($data->sheets[$i][cells]);
$sql="INSERT INTO `csc_customer` (`sr_no`,`pincode`,`company_name`, `csc_id`, `estore_name`, `vendor_name`, `estore_phoneno`, `alternate_number`, `document_type`, `document_no`, `vendor_email`, `distributor_name`, `distributor_phoneno`, `order_no`, `address`,`address1`, `district`, `state`, `gst_no`, `product_name`, `sku`, `quantity`,`mrp`, `payment_date`, `payment_mode`, `order_status`, `order_date`, `transcation_id`, `gatway_id`, `transcation_date`, `transcation_status`, `master_distribution`, `invoice_status`,`courier_company`, `import_date`) VALUES "	;

	for($j=1;$j<=count($data->sheets[$i][cells]);$j++) // loop used to get each row of the sheet
		{
		
			$more_record=1;	
			$sql.='(';
				
			for($k=1;$k<=34;$k++) // This loop is created to get data in a table format.
			{
				$sql.="'".Escape($data->sheets[$i][cells][$j][$k])."',";
				
				
			}
				
			$sql.="'".date('Y-m-d')."'";
				$sql.='),';
				

				if($r==1000000){
					$r=0;
					$sql = substr($sql, 0, strlen($sql)-1).';';	
					dbQuery($sql);					
					$more_record=0;	
					$sql = "";
				$sql="INSERT INTO `csc_customer` (`sr_no`,`pincode`,`company_name`, `csc_id`, `estore_name`, `vendor_name`, `estore_phoneno`, `alternate_number`, `document_type`, `document_no`, `vendor_email`, `distributor_name`, `distributor_phoneno`, `order_no`, `address`,`address1`, `district`, `state`, `gst_no`, `product_name`, `sku`, `quantity`,`mrp`, `payment_date`, `payment_mode`, `order_status`, `order_date`, `transcation_id`, `gatway_id`, `transcation_date`, `transcation_status`, `master_distribution`, `invoice_status`,`courier_company`, `import_date`) VALUES "	;
				}
			$r++;
		
	}
	
	if($more_record==1){
		 $sql = substr($sql, 0, strlen($sql)-1).';';	

	 	$res=dbQuery($sql);
		if($res==true)
		{
			echo'{"success":"true","msg":"Total '.$total.' row imported."}';

		}
		else
		{
			echo'{"success":"false","msg":"Error while importing data."}';
			exit;

		}
	}

	echo'{"success":"true","msg":"Total '.$total.' row imported."}'; 
	exit;
	

  ?>