<?php
 require "_header.php";

 

 if(isset($_POST["Import"])){
    
    $filename=$_FILES["file"]["tmp_name"];    
	print_r($filename); exit;
     if($_FILES["file"]["size"] > 0)
     {
        $file = fopen($filename, "r");
          while (($getData = fgetcsv($file, 10000, ",")) !== FALSE)
           {
           $sql = "INSERT into csc_customer(
			sr_no,
			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,
			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
			) 
			values('$emapData[0]','$emapData[1]','$emapData[2]','$emapData[3]','$emapData[4]','$emapData[5]','$emapData[6]','$emapData[7]'
			,'$emapData[8]','$emapData[9]','$emapData[10]','$emapData[11]','$emapData[12]','$emapData[13]','$emapData[14]'
			,'$emapData[15]','$emapData[16]','$emapData[17]','$emapData[18]','$emapData[19]','$emapData[20]','$emapData[21]','$emapData[22]','$emapData[23]','$emapData[24]','$emapData[25]','$emapData[26]','$emapData[27]','$emapData[28]','$emapData[29]')";
		
		echo $sql; exit;
		
				  $result = dbQuery($sql);
				  
			
		
        if(!isset($result))
        {
          echo "<script type=\"text/javascript\">
              alert(\"Invalid File:Please Upload CSV File.\");
              window.location = \"import_customer.php\"
              </script>";    
        }
        else {
            echo "<script type=\"text/javascript\">
            alert(\"CSV File has been successfully Imported.\");
            window.location = \"import_customer.php\"
          </script>";
        }
           }
      
           fclose($file);  
     }
  }   
 require "_footer.php";?>