
<?php
 header("Content-type: application/vnd.ms-excel");
 header("Content-Disposition: attachment; Filename=Product_Report.xls");
?>
<html>
  <body>
  <table border='1'>
  <tr border='1'>
  <th>Product Name</th>
  <th>Model</th>
  <th>M1</th>
  <th>M2</th>
  <th>M3</th>
  <th>G1</th>
  <th>G2</th>
  <th>G3</th>
  <th>G4</th>
  <th>G5</th>
  <th>Currency</th>

  <th>M1 Weight</th>
  <th>M1 Rate</th>
  <th>M2 Weight</th>
  <th>M2 Rate</th>
  <th>M3 Weight</th>
  <th>M3 Rate</th>
  
  <th>G1 Count</th>
  <th>G1 Weight</th>
  <th>G1 Rate</th>
  <th>G1 Size</th>
  <th>G1 Shape</th>
  <th>G2 Count</th>
  <th>G2 Weight</th>
  <th>G2 Rate</th>
  <th>G2 Size</th>
  <th>G2 Shape</th>
  <th>G3 Count</th>
  <th>G3 Weight</th>
  <th>G3 Rate</th>
  <th>G3 Size</th>
  <th>G3 Shape</th>
  <th>G4 Count</th>
  <th>G4 Weight</th>
  <th>G4 Rate</th>
  <th>G4 Size</th>
  <th>G4 Shape</th>
  <th>G5 Count</th>
  <th>G5 Weight</th>
  <th>G5 Rate</th>
  <th>G5 Size</th>
  <th>G5 Shape</th>
  
  <th>M1 Cost</th>
  <th>M2 Cost</th>
  <th>M3 Cost</th>
  <th>G1 Cost</th>
  <th>G2 Cost</th>
  <th>G3 Cost</th>
  <th>G4 Cost</th>
  <th>G5 Cost</th>
  <th>Setting Costs</th>
  <th>Weight-based Costs</th>
  <th>Total Metal Costs</th>
  <th>Total Gem Cost</th>
  <th>Product Cost</th>
  <th>Additional Cost</th>
  <th>Total Cost</th>
  </tr>

   <?php if ($products) { ?>
            <?php foreach ($products as $product) { ?>
            <tr border='1'>
			<td class="left"><?php echo $product['name']; ?></td>
              <td class="left"><?php echo $product['model']; ?></td>
              <td class="left"><?php echo $product['metal1']; ?></td>
              <td class="left"><?php echo $product['metal2']; ?></td>
              <td class="left"><?php echo $product['metal3']; ?></td>
              <td class="left"><?php echo $product['gem1']; ?></td>
              <td class="left"><?php echo $product['gem2']; ?></td>
              <td class="left"><?php echo $product['gem3']; ?></td>
              <td class="left"><?php echo $product['gem4']; ?></td>
              <td class="left"><?php echo $product['gem5']; ?></td>
			  
			  <td class="left"><?php echo $product['currency']; ?></td>
			  
              <td class="left"><?php echo $product['m1weight']; ?></td>
              <td class="left"><?php echo $product['m1rate']; ?></td>
              <td class="left"><?php echo $product['m2weight']; ?></td>
              <td class="left"><?php echo $product['m2rate']; ?></td>
              <td class="left"><?php echo $product['m3weight']; ?></td>
              <td class="left"><?php echo $product['m3rate']; ?></td>
			  
              <td class="left"><?php echo $product['g1count']; ?></td>
              <td class="left"><?php echo $product['g1weight']; ?></td>
              <td class="left"><?php echo $product['g1rate']; ?></td>
              <td class="left"><?php echo $product['g1size']; ?></td>
              <td class="left"><?php echo $product['g1shape']; ?></td>
              <td class="left"><?php echo $product['g2count']; ?></td>
              <td class="left"><?php echo $product['g2weight']; ?></td>
              <td class="left"><?php echo $product['g2rate']; ?></td>
              <td class="left"><?php echo $product['g2size']; ?></td>
              <td class="left"><?php echo $product['g2shape']; ?></td>
              <td class="left"><?php echo $product['g3count']; ?></td>
              <td class="left"><?php echo $product['g3weight']; ?></td>
              <td class="left"><?php echo $product['g3rate']; ?></td>
              <td class="left"><?php echo $product['g3size']; ?></td>
              <td class="left"><?php echo $product['g3shape']; ?></td>
              <td class="left"><?php echo $product['g4count']; ?></td>
			  <td class="left"><?php echo $product['g4weight']; ?></td>
              <td class="left"><?php echo $product['g4rate']; ?></td>
              <td class="left"><?php echo $product['g4size']; ?></td>
              <td class="left"><?php echo $product['g4shape']; ?></td>
              <td class="left"><?php echo $product['g5count']; ?></td>
              <td class="left"><?php echo $product['g5weight']; ?></td>
              <td class="left"><?php echo $product['g5rate']; ?></td>
              <td class="left"><?php echo $product['g5size']; ?></td>
              <td class="left"><?php echo $product['g5shape']; ?></td>
 
              <td class="left"><?php echo $product['m1cost']; ?></td>
              <td class="left"><?php echo $product['m2cost']; ?></td>
              <td class="left"><?php echo $product['m3cost']; ?></td>
              <td class="left"><?php echo $product['g1cost']; ?></td>
              <td class="left"><?php echo $product['g2cost']; ?></td>
              <td class="left"><?php echo $product['g3cost']; ?></td>
              <td class="left"><?php echo $product['g4cost']; ?></td>
              <td class="left"><?php echo $product['g5cost']; ?></td>
			  
              <td class="left"><?php echo $product['settingcost']; ?></td>
              <td class="left"><?php echo $product['weightcost']; ?></td>
			  
              <td class="left"><?php echo $product['totalmetalcost']; ?></td>
              <td class="left"><?php echo $product['totalgemcost']; ?></td>
              <td class="left"><?php echo $product['product_cost']; ?></td>
              <td class="left"><?php echo $product['additionalcost']; ?></td>
              <td class="left"><?php echo $product['totalcost']; ?></td>
			  
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr border='1'>
              <td class="center" colspan="10"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>
			
    </table>
  </body>
  </html>