<?php

header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=Export Certification.csv');

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

$msg="Export Certification\rSLN,Product Id,Gold Weight,Metal Type,Metal Color,Diamond Type,Diamond Quality,Diamond Color,Diamond Size,Diamond Quantity,Solitaire Type,Solitaire Quality,Solitaire Color,Solitaire Size,Solitaire Quantity\r\n";

$fetch_temp_product=$Mainclass->Fetch_multiple_data("gold_temp_product_master","*","SLN>0 and add_to_product='No' and igi_updation='No' and confirm='Yes' ORDER BY SLN DESC");
$i = 1; 

 foreach ($fetch_temp_product as $temp_product)
 {

$metal_type = "Gold";

if($temp_product['has_stone']=="Yes"){

$stone_name = $temp_product['StoneName'];
$stone_qty  = $temp_product['No_Stone'];

}

else{

$stone_name = "N/A";
$stone_qty  = "N/A";

}

if($temp_product['has_diamond']=="Yes"){

$Diamond_Creation_Type = $temp_product['Diamond_Creation_Type'];
$DiamondQuality  = $temp_product['DiamondQuality'];
$DiamondColor = $temp_product['DiamondColor'];
$DiamondType  = $temp_product['DiamondType'];
$No_Diamond  = $temp_product['No_Diamond'];
}

else{
$Diamond_Creation_Type = "-";
$DiamondQuality  = "N/A";
$DiamondColor = "N/A";
$DiamondType  = "N/A";
$No_Diamond  = "N/A";

}


if($temp_product['has_solitaire']=="Yes"){

$Solitaire_Creation_Type = $temp_product['Solitaire_Creation_Type'];
$SolitaireQuality  = $temp_product['SolitaireQuality'];
$SolitaireColor = $temp_product['SolitaireColor'];
$SolitaireType  = $temp_product['SolitaireType'];
$No_Solitaire  = $temp_product['No_Solitaire'];
}

else{
$Solitaire_Creation_Type = "N/A";
$SolitaireQuality  = "N/A";
$SolitaireColor = "N/A";
$SolitaireType  = "N/A";
$No_Solitaire  = "N/A";

}



 

$msg=$msg.$i.",".$temp_product['Product_Id'].",".$temp_product['GoldWeight'].",".$metal_type.",".$temp_product['Color'].",".$Diamond_Creation_Type.",".$DiamondQuality.",".$DiamondColor.",".$DiamondType.",".$No_Diamond.",".$Solitaire_Creation_Type.",".$SolitaireQuality.",".$SolitaireColor.",".$SolitaireType.",".$No_Solitaire."\r\n";


$i++;
}

echo $msg;
?>
