<?php ob_start(); ?>
	<!DOCTYPE html>
	<html>
	<?php include "layouts/db_connect.php";
				session_start('ERP');
				
				if($_SESSION['uname']==""&&$_SESSION['pwd']=="")
				{
				
					header("location:index.php");
				}
				
	if(isset($_SESSION['code'])) {
	  $code = $_SESSION['code'];
	  $scode = $_SESSION['code'];
	   $mfin = $_SESSION['mfin'];
		$staff = $_SESSION['name'];
		 $postt = $_SESSION['postt'];
	}
							if(isset($_POST))
							{
							    extract($_POST);
			$name = strtoupper($name);
			$fname = strtoupper($fname);
			$profession = strtoupper($profession);
			$co = strtoupper($co);
			$co01 = strtoupper($co01);
			$co02 = strtoupper($co02);
			$coaland = strtoupper($coaland);
			$lmark = strtoupper($lmark);
			$address = strtoupper($address);
			$address1 = strtoupper($address1);
			$address2 = strtoupper($address2);
			$oaddress = strtoupper($oaddress);
			$oaddress1 = strtoupper($oaddress1);
			$oaddress2 = strtoupper($oaddress2);
			$cobname = strtoupper($cobname);
			$cobname2 = strtoupper($cobname2);
				$remarks = strtoupper($remarks);
			
							    $selected_date2=$hpdate;
		  	$selected_date=strtotime( $selected_date2 );
	
				$geo = $geo;
				if($geo!=NULL){
					$sql55 = mysqli_query($conn, "select * from geo where code='$geo'");
					$row55 = mysqli_fetch_array($sql55);
					$lat = $row55['lat'];
					$lang = $row55['lang'];
				}
						date_default_timezone_set('Asia/Kolkata');
$date33 = date('h:i:s a m/d/y');
$dddttt =  date('h:i:s a d/m/y', strtotime($date33));			
			
			
			$img12 = $_POST['image'];
    $folderPath = "user/";
  
    $image_parts = explode(";base64,", $img12);
    $image_type_aux = explode("image/", $image_parts[0]);
    $image_type = $image_type_aux[1];
  
    $image_base64 = base64_decode($image_parts[1]);
    $fileName = uniqid() . '.png';
  
    $file = $folderPath . $fileName;
    file_put_contents($file, $image_base64);
	
	
							$uimg=$fileName;
							
							$img22 = $_POST['image1'];
    $folderPath = "user/";
  
    $image_parts = explode(";base64,", $img22);
    $image_type_aux = explode("image1/", $image_parts[0]);
    $image_type = $image_type_aux[1];
  
    $image_base64 = base64_decode($image_parts[1]);
    $fileName2 = uniqid() . '.png';
  
    $file = $folderPath . $fileName2;
    file_put_contents($file, $image_base64);
	
	
								$img=$fileName2;
								
								$i = 0;
			while($i <1){
$i++;				
				$ohp=$hp[$i];
$ov1=$v1[$i];
$ov2=$v2[$i];
$ov3=$v3[$i];
$ov4=$v4[$i];
$ov5=$v5[$i];
$ov6=$v6[$i];
$ov7=$v7[$i];
$ov8=$v8[$i];
$oa1=$a1[$i];
$oa2=$a2[$i];
$oa3=$a3[$i];
$oa4=$a4[$i];
$oa5=$a5[$i];
$oa6=$a6[$i];
$oa7=$a7[$i];
$oa8=$a8[$i];
$ot1=$t1[$i];
$ot2=$t2[$i];
$ot3=$t3[$i];
$ot4=$t4[$i];
$ot5=$t5[$i];
$ot6=$t6[$i];
$ot7=$t7[$i];
$ot8=$t8[$i];
$os1=$s1[$i];
$os2=$s2[$i];
$os3=$s3[$i];
$os4=$s4[$i];
$os5=$s5[$i];
$os6=$s6[$i];
$os7=$s7[$i];
$os8=$s8[$i];
$og1=$g1[$i];
$og2=$g2[$i];
$og3=$g3[$i];
$og4=$g4[$i];
$og5=$g5[$i];
$og6=$g6[$i];
$og7=$g7[$i];
$og8=$g8[$i];
$oc1=$c1[$i];
$oc2=$c2[$i];
$oc3=$c3[$i];
$oc4=$c4[$i];
$oc5=$c5[$i];
$oc6=$c6[$i];
$oc7=$c7[$i];
$oc8=$c8[$i];
$on1=$n1[$i];
$on2=$n2[$i];
$on3=$n3[$i];
$on4=$n4[$i];
$on5=$n5[$i];
$on6=$n6[$i];
$on7=$n7[$i];
$on8=$n8[$i];
$onetgram=$netgram[$i];
$oval=$val[$i];
$opcharge=$pcharge[$i];
$oboost=$boost[$i];
$ohpamount=$hpamount[$i];
$ointer=$inter[$i];
$ointerest=$interest[$i];
$odefamt=$defamt[$i];
$oduemnt=$duemnt[$i];
$odueamt=$dueamt[$i];
$ototal=$total[$i];
$pinter2=$pinter[$i];
$oimg=$img;
$ohpdate2=$hpdate2[$i];
$ohpdate=$hpdate[$i];
$ff = NULL;
if($ototal == 'NaN'){
$ototal = $ointerest;
$odueamt = 0;	
}
 $selected_date2=$ohpdate;
		  	$selected_date=strtotime( $selected_date2 );
		$ohpdate = date( 'd-m-Y', $selected_date );
		
			$hpdate5 = date( 'Y-m-d', $selected_date );
				
								//// card 1
								$insert=mysqli_query($conn, "insert into customerdetails(pinter,color,jft,sch,model,hplt,name,fname,address,address1,address2,lmark,pno,pnoresi,area,gg1,pmode,uimg,mfin,scode,createdate,hpdate5,status,hpl,v1,v2,v3,v4,v5,v6,v7,v8,a1,a2,a3,a4,a5,a6,a7,a8,t1,t2,t3,t4,t5,t6,t7,t8,s1,s2,s3,s4,s5,s6,s7,s8,g1,g2,g3,g4,g5,g6,g7,g8,c1,c2,c3,c4,c5,c6,c7,c8,n1,n2,n3,n4,n5,n6,n7,n8,netgram,val,pcharge,boost,hpamount,inter,interest,defamt,duemnt,dueamt,total,img,hpdate2,hpdate)
	  values('$pinter2','$color','$jft','$sch','$model','$hplt','$name','$fname','$address','$address1','$address2','$lmark','$pno','$pnoresi','$area','$gg1','$pmode','$uimg','$mfin','$scode','$dddttt','$hpdate5','Active','$ohp','$ov1','$ov2','$ov3','$ov4','$ov5','$ov6','$ov7','$ov8','$oa1','$oa2','$oa3','$oa4','$oa5','$oa6','$oa7','$oa8','$ot1','$ot2','$ot3','$ot4','$ot5','$ot6','$ot7','$ot8','$os1','$os2','$os3','$os4','$os5','$os6','$os7','$os8','$og1','$og2','$og3','$og4','$og5','$og6','$og7','$og8','$oc1','$oc2','$oc3','$oc4','$oc5','$oc6','$oc7','$oc8','$on1','$on2','$on3','$on4','$on5','$on6','$on7','$on8','$onetgram','$oval','$opcharge','$oboost','$ohpamount','$ointer','$ointerest','$odefamt','$oduemnt','$odueamt','$ototal','$oimg','$ohpdate2','$ohpdate')");

			}

$hpl=$ohp;
		$insert2=mysqli_query($conn, "insert into addr(mfin,hpl,addr,oadd,co,co2)
								values('$mfin55','$hpl','$name','$name','$cobname','$cobname')");
							//	$fname = "S/O ".$fname;
							//	$cofname = "S/O ".$cofname;
							//	$cofname2 = "S/O ".$cofname2;
								$insert3=mysqli_query($conn, "insert into addr(mfin,hpl,addr,oadd,co,co2)
								values('$mfin55','$hpl','$fname','$profession','$cofname',)");
								$insert4=mysqli_query($conn, "insert into addr(mfin,hpl,addr,oadd,co,co2)
								values('$mfin55','$hpl','$address','$oaddress','$co','$cow')");
								$insert5=mysqli_query($conn, "insert into addr(mfin,hpl,addr,oadd,co,co2)
								values('$mfin55','$hpl','$address1','$oaddress1','$co01','$cow01')");
								$insert6=mysqli_query($conn, "insert into addr(mfin,hpl,addr,oadd,co,co2)
								values('$mfin55','$hpl','$address2','$oaddress2','$co02','$cow02')");
								$insert7=mysqli_query($conn, "insert into addr(mfin,hpl,addr,oadd,co,co2)
								values('$mfin55','$hpl','$lmark','-','$coaland',)");
								$insert8=mysqli_query($conn, "insert into addr(mfin,hpl,addr,oadd,co,co2)
								values('$mfin55','$hpl','$pno','$pnooffice','$cobpno','$cobpno2')");
								
								if($insert)
								{
								
							
					
									//$move=move_uploaded_file($_FILES['uimg']['tmp_name'],"user/".$uimg);
//$move1=move_uploaded_file($_FILES['img']['tmp_name'],"user/".$img);
						echo "Success";
								
									$sqll = mysqli_query($conn, "select * from customerdetails where hpl='$hpl' && mfin='$mfin' order by id desc");
									$roww = mysqli_fetch_array($sqll);
									$idd = $roww['id'];
									header("Location:register11ss.php?fid=$idd");		
								//	echo "<script>alert('Register successfully Wait For Admin Approval');window.location.href='register11ss.php?fid=".$idd."'</script><br>"; 
								}
								else
								{
									echo "Failure";
								}
							}
?>
</html>