<?php
//session_start();
include("script/condb.php");
require_once("dompdf2/autoload.inc.php");
use Dompdf\Dompdf;
extract($_POST);

if(isset($_POST['submit'])){
$sql="select * from upline_app_materials";
$query= mysql_query($con, $sql);
$html ='';
$html .='
	<h2 align="center">Material Report Summary</h2>
	<table style="width:100%; border-collapse:collapse;"> 
	<tr>
	<th style="border:1px solid #ddd; padding:8px; text-align:left;">SN</th>
	<th style="border:1px solid #ddd; padding:8px; text-align:left;">Material Name</th>
	<th style="border:1px solid #ddd; padding:8px; text-align:left;">Material Width</th>
	<th style="border:1px solid #ddd; padding:8px; text-align:left;">Material Height</th>
	<th style="border:1px solid #ddd; padding:8px; text-align:left;">Material Cost</th>
	<th style="border:1px solid #ddd; padding:8px; text-align:left;">Material UOM</th>

	</tr>
   ';

	if(mysql_num_rows($query) > 0){	
          $count = 1;
	 foreach($query as $data){
           $html .= '
             <tr>
                 <td style="border:1px solid #ddd; padding:8px; text-align:left;">'.$count.'</td>
		<td style="border:1px solid #ddd; padding:8px; text-align:left;">'.$data["material_namee"].'</td>
		<td style="border:1px solid #ddd; padding:8px; text-align:left;">'.$data["material_width"].'</td>
		<td style="border:1px solid #ddd; padding:8px; text-align:left;">'.$data["material_height"].'</td>
		<td style="border:1px solid #ddd; padding:8px; text-align:left;">'.$data["material_price"].'</td>
		<td style="border:1px solid #ddd; padding:8px; text-align:left;">'.$data["material_uom"].'</td>
            </tr>		
		';
		$count++;
         
	}
}else{
	$html .='
	  <tr>
           <td colspan="5" style="border:1px solid #ddd; padding:8px; text-align:left;"> No Data </td>
          </tr>
		  ';
			
}
$html .='</table>';
$dompdf= new DOMPDF();
$dompdf->loadHtml($html);
$dompdf->setPaper("A4", "portrait");
$dompdf->render();
$dompdf->stream("material_export.pdf", ['Attachment'=>0]);

}
?> 