<?php 
session_start();
ob_start();
include("../../pidbco/pidbjoin.php");
$sujpath="./";


if(isset($_POST["submit"]))
	{
		$file = $_FILES['file']['tmp_name'];
		$handle = fopen($file, "r");
		$c = 0;
		while(($filesop = fgetcsv($handle, 1000, ",")) !== false)
		{
			$dom1 = $filesop[0];
			$dom2 = $filesop[1];
			$domine = $dom1.$dom2;
			$regdate = $filesop[2];
			$renewal = $filesop[3];
			$intim_dat = $filesop[4];
			$dom_cost = $filesop[5];
			$remarks = $filesop[6];
			$company = $filesop[7];
			$contact = $filesop[8];
			$mob = $filesop[9];
			$email = $filesop[10];
			$country = $filesop[11];
			$state = $filesop[12];
			$dist = $filesop[13];
			$s_regdate = $filesop[14];
			$s_expdat = $filesop[15];
			$s_space = $filesop[16];
			$s_rate = $filesop[17];
			$server_rate = $s_space * $s_rate;  
			$s_remarks = $filesop[18];
			
			
			
			$sq2 = mysqli_query($con,"SELECT MAX(`cid`) AS mxid FROM `p_customers`");
            $rs2 = mysqli_fetch_array($sq2);
            $cust_id = $rs2['mxid']+1;
			
			$dat = date('Y-m-d');	
			
			$sq1 = mysqli_query($con, "INSERT INTO `p_customers` (`cidentity` ,`cname` ,`ccontact` ,`cmob` ,`cemail` ,`ccountry` ,`cstate` ,
`cdistrict` ,`cstatus` ,`cdate`) VALUES ('$cust_id','$company', '$contact', '$mob', '$email', '$country', '$state', '$dist', '1', '$dat')");
			
			$sq4 = mysqli_query($con, "INSERT INTO `p_domain` ( `dcust`, `d_domain`, `d_regdate`, `d_renewel`, `d_intimation`, `d_amnt`, `d_remarks`)
			 VALUES ('$cust_id', '$domine', '$regdate', '$renewal', '$intim_dat', '$dom_cost', '$remarks')");
			
			$sq5 = mysqli_query($con, "INSERT INTO `p_server` (`s_cust`, `s_start`, `s_end`, `s_amnt`, `s_remarks`) 
			VALUES ('$cust_id', '$regdate', '$s_expdat', '$server_rate', '$s_remarks');");
			
			
			$c = $c + 1;
		}
		
			if($sql){
				echo "You database has imported successfully. You have inserted ". $c ." recoreds";
			}else{
				echo "Sorry! There is some problem.";
			}

	}
?>

	<style type="text/css">
	body
	{
		margin: 0;
		padding: 0;
		background-color:#D6F5F5;
		text-align:center;
	}
	.top-bar
		{
			width: 100%;
			height: auto;
			text-align: center;
			background-color:#FFF;
			border-bottom: 1px solid #000;
			margin-bottom: 20px;
		}
	.inside-top-bar
		{
			margin-top: 5px;
			margin-bottom: 5px;
		}
	.link
		{
			font-size: 18px;
			text-decoration: none;
			background-color: #000;
			color: #FFF;
			padding: 5px;
		}
	.link:hover
		{
			background-color: #9688B2;
		}
	</style>
	
	<script>
	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	  ga('create', 'UA-60962033-1', 'auto');
	  ga('send', 'pageview');

	</script>

  <form name="import" method="post" enctype="multipart/form-data">
    	<input type="file" name="file" /><br />
        <input type="submit" name="submit" value="Submit" />
    </form>