<?php session_start();
ob_start();
?>

<?php
ini_set('memory_limit', '512M');


//echo "Search option is " . $search_option;


$supp_id =  $_GET['supp_id'];

//echo "davesupp_id = " . $supp_id;

$ac = 0;



	include("../php/configi.php");


		$query_pag_data = "select * from " . $_COOKIE["phxcrmclient_id"] . "_client where uid_client = " . $supp_id;

//	echo $query_pag_data;

$result_pag_data = mysqli_query($conn, $query_pag_data);
while ($row = mysqli_fetch_array($result_pag_data)) {
$prod_suppname = $row["comp_name"];
}
	

$msg = "";

$report =  '<table style="width: 735px">
<tr>
  <td class="auto-style1"><img src="http://app.phoenixcrm.co.nz/crm/images/logo/142.jpg"/></td>
  <td valign="top">I Love Labels<br />
      5 Margaret Rd<br />
      Raumati Beach<br />
      Ph: (027) 578 1692 <br />
      email: <a href="mailto:info@ilovelabels.nz">info@ilovelabels.nz</a><br />
    </td>
</tr>
<tr>
  <td class="auto-style1">&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr>
  <td style="text-align: center; font-size: 16px;" colspan="2">Sold Items Report</td>
</tr>
<tr>
  <td style="text-align: center;" colspan="2"><span style="font-size: 14px;">Supplier of goods: ' . $prod_suppname . ' </span> </td>
</tr>
<tr>
<td>
<br>
<br>
</td>
</tr>

</table>



<table border="0" bgcolor="white">

<tr>
<td width="50px" valign="top">

</td>

<td width="80px" valign="top" align="left">
Prod Code:
</td>

<td width="300px" valign="top" align="left">
Title:
</td>
<td width="80px" valign="top" align="left">
Buy price for you$:
</td>
<td width="80px" valign="top" align="left">
Status:
</td>
<td width="80px" valign="top" align="left">
Sold Date:
</td>

</tr>


<tr>

 ';



$i = 0;
$d = 0;
 
		$query_pag_data = "select * from " . $_COOKIE["phxcrmclient_id"] . "_prod_search where prod_suppid = " . $supp_id . " and prod_status = 'Sold' order by prod_date_sold";

//	$report = $report .  $query_pag_data;
//echo $query_pag_data;
 
$i2 = 1;
$result_pag_data = mysqli_query($conn, $query_pag_data);
while ($row = mysqli_fetch_array($result_pag_data)) {
 // echo "row";
 
 				  $prod_date_sold2 = date('d-m-Y', strtotime($row["prod_date_sold"])); 
				  if ($prod_date_sold2 == "01-01-1970"){
					$prod_date_sold2 = "";
				  }

  $payvar = "";


  $report = $report . ' <tr>
  <td>
</td>


<td width="60px" valign="top">

' .  $row["sel_uid"] . ' 
		
			</td>

<td  width="200px" valign="top">

  ' .  $row["title"] . '

			</td>
			
			
			

						   <td valign="top">
			

						   
				$ ' . number_format($row["prod_cost_price"],2,".",",") . '

			
			</td>
						   <td valign="top">
	
			' . $row["prod_status"] . '
				
			</td>
									   <td valign="top">
	
			' . $prod_date_sold2 . '
				
			</td>

</tr>  </tr>';
 
  


  $i2 = $i2 + 1;
  

  $i = $i + 1;
  
  }

  
 $report = $report . ' </table>    <br>     <br>   <br>';


 
  $i2 = $i2 + 1;
  
  $i = $i + 1;
  

 $report = $report . '</tbody> </table>';


/* --------------------------------------------- */
//echo $report;
//==============================================================
//==============================================================
//==============================================================
//echo $report;


include("mpdflatest/mpdf.php");


$mpdf=new mPDF('','', 0, '', 6, 6, 10, 10, 9, 9, 'P');

$mpdf->SetDisplayMode('fullpage');

$mpdf->WriteHTML($report);	// Separate Paragraphs  defined by font

$mpdf->Output(); 

exit;


?>