<?= $this->extend('layouts/main.php') ?>

<?= $this->section('content') ?>
<?php
$crm_products = array();
foreach($products as $data) {
	$crm_products[$data['productid']] ['productname'] = $data['productname'];
	$crm_products[$data['productid']] ['sitename'] = $data['sitename'];
	$crm_products[$data['productid']] ['productnumber'] = $data['productnumber'];
}
?>
<div class="page-wrapper">
	<div class="container-fluid">
		<div class="row page-titles">
			<div class="col-md-5 align-self-center">
				<h4 class="text-themecolor">Product / Instrument List</h4>
			</div>
		</div>
		
		<div class="row">
			<div class="col-12">
				<div class="card">
					<div class="card-body">
						<div class="table-responsive">
							<table id="myTable" class="table display table-striped border">
								<thead>
									<th></th> <th>Site</th> <th>Products</th> <th></th>
								</thead>
								<tbody>
									<?php
									foreach($clqms_products as $data) {
										$qproductid = $data['productid'];
										$qsitename = $crm_products[$qproductid]['sitename'];
										$qproductname = $crm_products[$qproductid]['productname'];
										$qproductnumber = $crm_products[$qproductid]['productnumber'];
										$qprodinstid = $data['prodinstid'];
										echo "<tr> <td>$qproductid</td> <td>$qsitename</td> <td>$qproductname ($qproductnumber)</td> 
											<td><a href='https://clqms.services-summit.my.id/prodinst/detail/$qprodinstid' class='btn btn-sm btn-info' target='_blank'>View</a></td> 
											</tr>";
									}
									?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<?= $this->endSection() ?>

<?= $this->section('script') ?>
<?= $this->endSection() ?>