<?php
// create log data
$logs = array();
foreach($products_log as $key => $data) {
	$logs[$key] = $data;
}
// current data
$data = $products[0];
$productid = $data['productid'];
$productname = $data['productname'];
$productnumber = $data['productnumber'];
$catalognumber = $data['catalognumber'];
$sitename = $data['sitename'];
$productowner = $data['productowner'];
if($data['createdate'] != '' ) { $createdate = date('Y-m-d', strtotime($data['createdate'])); }
else { $createdate = ''; }
if($data['locationstartdate'] != '' ) { $locationstartdate = date('Y-m-d', strtotime($data['locationstartdate'])); }
else { $locationstartdate = ''; }
if($data['locationenddate'] != '' ) { $locationenddate = date('Y-m-d', strtotime($data['locationenddate'])); }
else { $locationenddate = ''; }
$installationdate = $data['installationdate'];
$warrantystartdate = $data['warrantystartdate'];
$warrantyenddate = $data['warrantyenddate'];
$productservicetext = $data['productservicetext'];
$statuspart = $data['statuspart'];
$remotetool = $data['remotetool'];
$remoteid = $data['remoteid'];
$remotepwd = $data['remotepwd'];
?>
<div class="modal-header">
	<h4 class="modal-title" id="tooltipmodel">Product Detail <?=$productid;?></h4>
	<button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true"></button>
</div>
<div class="modal-body">
	<div class='table-responsive'>
		<table class='table'>
			<tr> 
				<th></th> <th>Now</th> 
				<?php 
				foreach($logs as $data) { 
				?>
					<th><?=$data['logdate'];?><br /> 
						<a class='btn btn-sm btn-warning' href='<?=base_url();?>/products/log/edit/<?=$data['productlogid'];?>' 
							onclick="window.open(this.href, 'editor','width=900,height=600,toolbar=1,resizable=0'); return false;">
							<i class="fas fa-pencil"></i> Edit
						</a>
						<a class='btn btn-sm btn-danger' onclick="productslog_delete(<?=$data['productlogid'];?>)" >
							<i class="fas fa-trash"></i> Delete
						</a>
					</th>
				<?php
				} 
				?>
			</tr>
			<tr> 
				<td>Product# (SN.)</td> <td><?=$productnumber;?></td>
			</tr>
			<tr> 
				<td>Catalog#</td> <td><?=$catalognumber;?></td>
				<?php foreach($logs as $data) { echo "<td>".$data['catalognumber']."</td>"; } ?>
			</tr>
			<tr> 
				<td>ProductName</td> <td><?=$productname;?></td>
				<?php foreach($logs as $data) { echo "<td>".$data['productname']."</td>"; } ?>
			</tr>
			<tr> 
				<td>Site</td> <td><?=$sitename;?></td>
				<?php foreach($logs as $data) { echo "<td>".$data['sitename']."</td>"; } ?>
			</tr>
			<tr> 
				<td>Location StartDate</td> <td><?=$locationstartdate;?></td>
				<?php foreach($logs as $data) { echo "<td>".$data['locationstartdate']."</td>"; } ?>
			</tr>
			<tr> 
				<td>Installation Date</td> <td><?=$installationdate;?></td>
				<?php foreach($logs as $data) { echo "<td>".$data['installationdate']."</td>"; } ?>
			</tr>
			<tr> 
				<td>Location EndDate</td> <td><?=$locationenddate;?></td>
				<?php foreach($logs as $data) { echo "<td>".$data['locationenddate']."</td>"; } ?>
			</tr>
			<tr> 
				<td>Warranty StartDate</td> <td><?=$warrantystartdate;?></td>
				<?php foreach($logs as $data) { echo "<td>".$data['warrantystartdate']."</td>"; } ?>
			</tr>
			<tr>
				<td>Warranty EndDate</td> <td><?=$warrantyenddate;?></td>
				<?php foreach($logs as $data) { echo "<td>".$data['warrantyenddate']."</td>"; } ?>
			</tr>
			<tr>
				<td>Product Owner</td> <td><?=$productowner;?></td>
				<?php foreach($logs as $data) { echo "<td>".$data['productowner']."</td>"; } ?>
			</tr>
			<tr>
				<td>Status Part</td> <td><?=$statuspart;?></td>
			</tr>
			<tr>
				<td>Remote tool</td> <td><?=$remotetool;?></td>
			</tr>
			<tr>
				<td>Remote id</td> <td><?=$remoteid;?></td>
			</tr>
			<tr> 
				<td>Remote password</td> <td><?=$remotepwd;?></td>
			</tr>
			<tr> 
				<td>Create Date</td> <td><?=$createdate;?></td>
			</tr>			
		</table>
	</div>
</div>
<div class="modal-footer">
	<button type="button" class="btn btn-info waves-effect text-white" data-bs-dismiss="modal">Close</button>
</div>
