<?php include('../../config/setup.php');?>
<?php
error_reporting(0);
if(isset($_POST['product_price_add']))
{
	
// 	$Add_pro_game_support= array_filter( $_POST['Add_pro_game_support']);
// $support_image=array_values(array_filter($_FILES['support_image']['name']));
// $prod_price=array_values(array_filter($_POST['prod_price']));
// $shell_price=array_values( array_filter($_POST['shell_price']));
//  $tempname = array_values(array_filter($_FILES["support_image"]["tmp_name"]));


// $pid=$_POST['Add_pro_name'];
// $i=0;
//  foreach($support_image as $val){  
// 	$addsugcatephoto=$val;
// 	 $addsubphoto="../../../photos/Product/".$addsugcatephoto;
// 	 move_uploaded_file($tempname[$i],$addsubphoto);
// 	 $taxadd=0;
// 	 $sellprice=$shell_price[$i];
// 	  // $shpice=(($sproud * $taxadd ) / 100);
// 	  // $sellprice=($shpice + $sproud );
// 	$offer_per = (100 * ($prod_price[$i] -  $sellprice) / $prod_price[$i] );
// 	$maincate=date('Y-m-d');
	
// 	  $p_p_d="insert into product_price_master(Product_id,P_image,Product_type,Product_price,Shelling_price,Offer_Percent,Product_price_Add_on,Product_status)
// 	values('$pid','$addsugcatephoto','".$Add_pro_game_support[$i]."','".$prod_price[$i]."','".$sellprice."','$offer_per','$maincate','1')";
// 	 $addprotype=mysqli_query($config,$p_p_d);
// 	$i++;
	
	
// 	  }
$i=0;
$pid=$_POST['Add_pro_name'];
$color=$_POST['color'];
$length=$_POST['length'];
$weight=$_POST['weight'];
$texture=$_POST['texture'];
$prod_price=$_POST['Add_pro_price'];
$shell_price=$_POST['Add_pro_shelling_price'];
$p_img=$_FILES['support_image']['name'];
$p_tmp=$_FILES["support_image"]["tmp_name"];
  foreach($color as $val){  
$addsugcatephoto=$p_img[$i];
    $addsubphoto="../../../photos/Product/".$addsugcatephoto;
     move_uploaded_file($p_tmp[$i],$addsubphoto);


 $sellprice=$shell_price[$i];


    $p_p_d="insert into product_price_master(Product_id,P_image,Product_type,	Product_length,Product_price,Shelling_price,Offer_Percent,product_stock,product_tax,Product_price_Add_on,Product_status,p_weight,p_texture)
values('$pid','$addsugcatephoto','$val','".$length[$i]."','".$prod_price[$i]."','".$sellprice."','0','100','18','$maincate','1','".$weight[$i]."','".$texture[$i]."')";
 $addprotype=mysqli_query($config,$p_p_d);
$i++;


  
}

if($addprotype==false)
{
 	
 	 echo "<script>window.location.href='../Product_price_Master.php?erro=0';</script>".mysqli_error();	 
}
else{
	
	echo "<script>window.location.href='../Product_price_Master.php?msg=505';</script>";	 

	
}	







}
?>
