<?php
session_start();
if($_SESSION['dbName']==""){
header("location:../index.php");
}
include('config.inc.php');

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

$RMA_Id = $_GET['RMA_Id'];

print <<<HERE
<html>
<head>
<title>Service Center Report</title>
</head>
<body>
HERE;
$query_rmadt = "select rma.rma_reference as RMAReference, rmadt.item_code as ItemCode, date_format(rma.rma_date, '%d/%m/%Y %H:%i:%s')  as ItemSent, rmadt.rmadt_problem,
rmadt.rmadt_received
from rma inner join rmadt on rmadt.rma_id = rma.rma_id
where rmadt.rma_id = $RMA_Id";
$result_rmadt = mysql_query($query_rmadt, $connection);
while($row_rmadt = mysql_fetch_array($result_rmadt)){
	extract($row_rmadt);
echo "<div style='width: 750px;'>
<div style='padding: 15px; text-align: center; font-family: Arial; font-weight: bold; font-size: 22px'>Service Center Report</div>
<table width=750 style='border-collapse: collapse'>
<tr>
<th colspan=2 style='font-size: 20px; font-family: Arial; border-top: solid 2px #000000; border-left: solid 2px #000000; border-right: solid 2px #000000; border-bottom: solid 1px #000000;'>Details</th>
</tr>
<tr>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 150px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px;'>RMA #</td>
<td style='font-family: Arial; font-size: 18px; width: 600px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000;'>$RMAReference</td>
</tr>
<tr>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 150px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px;'>Item</td>
<td style='font-family: Arial; font-size: 18px; width: 600px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000;'>$ItemCode</td>
</tr>
<tr>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 150px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px;'>Date Sent</td>
<td style='font-family: Arial; font-size: 18px; width: 600px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000;'>$ItemSent</td>
</tr>
<tr style='height: 150px'>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 150px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px; vertical-align: top;'>Problem</td>
<td style='font-family: Arial; font-size: 18px; width: 600px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000; vertical-align: top;'>$rmadt_problem</td>
</tr>
<tr>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 150px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px;'>Including</td>
<td style='font-family: Arial; font-size: 18px; width: 600px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000;'>$rmadt_received</td>
</tr>
<tr style='height: 10px'>
<th colspan=2 style='font-size: 20px; font-family: Arial; border: solid 1px #000000; border-left: solid 2px #000000; border-right: solid 2px #000000'></th>
</tr>
<tr>
<th colspan=2 style='font-size: 20px; font-family: Arial; border-top: solid 1px #000000; border-left: solid 2px #000000; border-right: solid 2px #000000; border-bottom: solid 1px #000000;'>Repaired</th>
</tr>
<tr>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 150px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px;'>Part repaired</td>
<td style='font-family: Arial; font-size: 18px; width: 600px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000;'></td>
</tr>
<tr>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 150px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px;'>Part exchanged</td>
<td style='font-family: Arial; font-size: 18px; width: 600px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000;'></td>
</tr>
<tr style='height: 80px;'>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 150px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px; vertical-align: top;'>Notes</td>
<td style='font-family: Arial; font-size: 18px; width: 600px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000;'></td>
</tr>
<tr style='height: 10px'>
<th colspan=2 style='font-size: 20px; font-family: Arial; border: solid 1px #000000; border-left: solid 2px #000000; border-right: solid 2px #000000'></th>
</tr>
<tr>
<th colspan=2 style='font-size: 20px; font-family: Arial; border-top: solid 1px #000000; border-left: solid 2px #000000; border-right: solid 2px #000000; border-bottom: solid 1px #000000;'>Unrepaired</th>
</tr>
</table>
<table width=750 style='border-collapse: collapse'>
<tr style='height: 70px;'>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 350px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px; vertical-align: top;'>Problem From (Detailed)</td>
<td style='font-family: Arial; font-size: 18px; width: 400px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000;'></td>
</tr>
<tr style='height: 70px;'>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 350px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px; vertical-align: top;'>Couldn't be fixed because</td>
<td style='font-family: Arial; font-size: 18px; width: 400px; border: solid 1px #000000; padding: 10px; padding-left: 25px; padding-top: 15px; padding-bottom: 20px; border-right: solid 2px #000000;'>[ ] No spare parts found <br><br>[ ] Other (Please specify):</td>
</tr>
<tr style='height: 70px;'>
<td style='font-weight: bold; font-family: Arial; font-size: 18px; width: 350px; border: solid 1px #000000; border-left: solid 2px #000000; padding: 10px; vertical-align: top;'>Notes / Tests performed</td>
<td style='font-family: Arial; font-size: 18px; width: 400px; border: solid 1px #000000; padding: 10px; border-right: solid 2px #000000;'></td>
</tr>
</table>
<table width=750 style='border-collapse: collapse'>
<tr>
<td width=50% style='padding-left: 15px; padding-top: 20px; font-size: 18px; font-weight: bold; font-family: Arial; border-left: solid 2px #000000;'>Received by:</td>
<td width=50% style='padding-left: 15px; padding-top: 20px; font-size: 18px; font-weight: bold; font-family: Arial; border-right: solid 2px #000000'>Technician who worked on it:</td>
</tr>
<tr>
<td width=50% style='padding-left: 15px; padding-top: 20px; font-size: 18px; font-weight: bold; font-family: Arial; border-left: solid 2px #000000;'>Date:</td>
<td width=50% style='padding-left: 15px; padding-top: 20px; font-size: 18px; font-weight: bold; font-family: Arial; border-right: solid 2px #000000'>Date finalized:</td>
</tr>
<tr>
<td width=50% style='padding-left: 15px; padding-top: 20px; font-size: 18px; font-weight: bold; font-family: Arial; border-left: solid 2px #000000; padding-bottom: 45px; border-bottom: solid 2px #000000'>Signature:</td>
<td width=50% style='padding-left: 15px; padding-top: 20px; font-size: 18px; font-weight: bold; font-family: Arial; border-right: solid 2px #000000; padding-bottom: 45px; border-bottom: solid 2px #000000'>Signature:</td>
</tr>
</table>
</div>";
echo "<div style='page-break-after: always;'></div>";
}
print <<<HERE
<script>
window.print();
</script>
HERE;
?>