<?php
include("db_connection.php");
$Mainclass = new DB_Controller();

$Last_P_Code = $_REQUEST['Last_P_Code'];
$p_cate = $_REQUEST['p_cate'];
$metal_type = $_REQUEST['metal_type'];

if($metal_type=="GOLD"){

 $final_metal_type= "G";   
}

if($metal_type=="SILVER"){

 $final_metal_type= "S";   
}


$design_id = $_REQUEST['design_id'];
$p_name = $Mainclass->real_escapes(strip_tags($_REQUEST['p_name']));
$h_code = $_REQUEST['h_code'];
$g_purity = $_REQUEST['g_purity'];

$stone_array = $_REQUEST['s_name'];
$stone_data = '';
foreach ($stone_array as $stone) {
    $stone_data .= "," . $stone;
}
$s_name = ltrim($stone_data, ",");
$no_stones = $_REQUEST['no_stones'];
$stone_value = $_REQUEST['stone_value'];

$diamond_type = $_REQUEST['diamond_type'];
$quality = $_REQUEST['quality'];
$color = $_REQUEST['color'];
$type = $_REQUEST['type'];
$no_diamonds = $_REQUEST['no_diamonds'];
$diamond_value = $_REQUEST['diamond_value'];

$sol_diamond_type = $_REQUEST['sol_diamond_type'];
$sol_quality = $_REQUEST['sol_quality'];
$sol_color = $_REQUEST['sol_color'];
$sol_type = $_REQUEST['sol_type'];
$sol_no_diamonds = $_REQUEST['sol_no_diamonds'];
$sol_diamond_value = $_REQUEST['sol_diamond_value'];

$size_variation = $_REQUEST['size_variation'];
$p_color = $_REQUEST['p_color'];
$mk_ch = $_REQUEST['mk_ch'];
$mk_ch_val = $_REQUEST['mk_ch_val'];
$wc = $_REQUEST['wc'];
$MRP = $_REQUEST['MRP'];
$remark = $Mainclass->real_escapes(strip_tags($_REQUEST['remark']));

//$parent_code = $Mainclass->parent_code($final_metal_type, $p_cate, $design_id);


$DateTime=date('Y-m-d H:i:s');
$IP = $_SERVER['REMOTE_ADDR'];
$Added_By = $_COOKIE['User'];


if($no_stones==""){
    
  $has_stone = "No";  
    
}

else{
    
  $has_stone = "Yes";    
}


if($no_diamonds==""){
    
  $has_diamond = "No";  
    
}

else{
    
  $has_diamond = "Yes";    
}

if($sol_no_diamonds==""){
    
  $has_solitaire = "No";  
    
}

else{
    
  $has_solitaire = "Yes";    
}


$table = "design_code_master";

$Fields = "ProductCategory, Metal_Type, ParentId, ProductName, HSNCode, GoldPurity, StoneName, No_Stone, Stone_Value, Diamond_Creation_Type, DiamondQuality, DiamondColor, DiamondType, No_Diamond, Diamond_Value, Solitaire_Creation_Type, SolitaireQuality, SolitaireColor, SolitaireType, No_Solitaire, Solitaire_Value, Has_Size_Variation,  MakingChargesType, MakingChargesValue,WastageCost, Remark, Added_On, Added_By, IP, Inactive, has_stone, has_diamond, has_solitaire, Color,MRP";

$Values = " '$p_cate', '$metal_type', '$design_id', '$p_name', '$h_code', '$g_purity', '$s_name', '$no_stones', '$stone_value','$diamond_type','$quality','$color','$type','$no_diamonds','$diamond_value','$sol_diamond_type','$sol_quality','$sol_color','$sol_type','$sol_no_diamonds','$sol_diamond_value', '$size_variation', '$mk_ch', '$mk_ch_val', '$wc', '$remark', '$DateTime', '$Added_By', '$IP', '0', '$has_stone', '$has_diamond', '$has_solitaire', '$p_color', '$MRP'";
$result = $Mainclass->Insert_Data($table, $Fields, $Values);

$Mainclass->Update_Data("gold_product_category_master","Last_P_Code='".$Last_P_Code."'","SLN='".$p_cate."'");

?>