<div class="row mt-3">

    <!-- Baris 0 (TOP 3 PARTS REPLACED) -->
	<div class='col-12 col-lg-6'>
		<div class="card" style="height:15rem;">
			<h5 class="card-header text-center fw-bold">TOP 3 PARTS REPLACED</h5>
			<div class="card-body">
				
				<table class='table small table-bordered'>
					<thead class='table-info'>
						<tr style='text-align: center;'>
							<th>PART NO.</th>
							<th>DESCRIPTION</th>
							<th>&Sigma;</th>
						</tr>
					</thead>
					<tbody>
						<?php foreach ($most_part_replaced as $row) { ?>
							<tr>
								<td><?= $row['catalognumber'] ?></td>
								<td><?= $row['productname'] ?></td>
								<td  class='text-center'><?= (int)$row['total_qty'] ?></td>
							</tr>
						<?php } ?>
					</tbody>
				</table>

			</div>
		</div>
	</div>
	<!-- Baris 0 (CERTIFICATES NEED TO BE SIGNED) -->
	<div class='col-12 col-lg-6'>
		<div class="card" style="height:15rem;">
			<h5 class="card-header text-center fw-bold">CERTIFICATES NEED TO BE SIGNED</h5>
			<div class="card-body">
				
				<table class='table small'>
					<thead>
						<tr style='text-align: center;'>
							<th>SITES</th>
							<th>TYPE</th>
						</tr>
					</thead>
					<tbody>
						
					</tbody>
				</table>

			</div>
		</div>
	</div>
    
	<!-- Baris 1 (SPARE PARTS REPLACEMENT THIS MONTH) -->
	<div class="col-12">
		<div class="card">
			<div class="card-header">
				<h4 class='text-center fw-bold mt-1'>SPARE PARTS REPLACEMENT - THIS MONTH</h4>
			</div> 
			<div class="card-body">
				<div class="row">
					<div class="col-12 col-lg-4 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='4'><h5>TSO - BARAT</h5></th></tr>
								<tr style='text-align: center;'>
									<th style="width:auto;">PRINCIPAL</th>
									<th style="width:19%;">&Sigma; PARTS</th>
									<th style="width:18%;">&Sigma; INST.</th>
									<th style="width:10%;">RATIO</th>
								</tr>
							</thead>
							<tbody>
								<?php foreach($replacement_barat as $data) { ?>
									<?php if($data['vendorname']==null) {continue;} ?>
									<tr>
										<td> <?=$data['vendorname']?> </td>
										<td class='text-center'> <?=$data['total_qty']?> </td>

										<?php foreach($replacement_vendor_barat as $data2) { ?>
											<?php if($data['vendorid'] == $data2['vendorid']) { ?>
												<td class='text-center'><?=$data2['banyak_vendor']?></td>
											<?php break; } else { ?>
											<?php } ?>
										<?php } ?>
										<td class='text-center'><?= ($data['total_qty']/$data2['banyak_vendor'] > 0 ) ? number_format($data['total_qty']/$data2['banyak_vendor'], 2, '.', '') : 0;?></td>
										</tr>
								<?php } ?>
							</tbody>
						</table>
					</div>

					<div class="col-12 col-lg-4 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='4'><h5>TSO - TENGAH</h5></th></tr>
								<tr style='text-align: center;'>
									<th style="width:auto;">PRINCIPAL</th>
									<th style="width:19%;">&Sigma; PARTS</th>
									<th style="width:18%;">&Sigma; INST.</th>
									<th style="width:10%;">RATIO</th>
								</tr>
							</thead>
							<tbody>
								<?php foreach($replacement_tengah as $data) { ?>
									<?php if($data['vendorname']==null) {continue;} ?>
									<tr>
										<td> <?=$data['vendorname']?> </td>
										<td class='text-center'> <?=$data['total_qty']?> </td>
										<?php foreach($replacement_vendor_tengah as $data2) { ?>
											<?php if($data['vendorid'] == $data2['vendorid']) { ?>
												<td class='text-center'><?=$data2['banyak_vendor']?></td>
											<?php break; } else { ?>
											<?php } ?>
										<?php } ?>
										<td class='text-center'><?= ($data['total_qty']/$data2['banyak_vendor'] > 0 ) ? number_format($data['total_qty']/$data2['banyak_vendor'], 2, '.', '') : 0;?></td>
										</tr>
								<?php } ?>
							</tbody>
						</table>
					</div>

					<div class="col-12 col-lg-4 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='4'><h5>TSO - TIMUR</h5></th></tr>
								<tr style='text-align: center;'>
									<th style="width:auto;">PRINCIPAL</th>
									<th style="width:19%;">&Sigma; PARTS</th>
									<th style="width:18%;">&Sigma; INST.</th>
									<th style="width:10%;">RATIO</th>
								</tr>
							</thead>
							<tbody>
								<?php foreach($replacement_timur as $data) { ?>
									<?php if($data['vendorname']==null) {continue;} ?>
									<tr>
										<td> <?=$data['vendorname']?> </td>
										<td class='text-center'> <?=$data['total_qty']?> </td>

										<?php foreach($replacement_vendor_timur as $data2) { ?>
											<?php if($data['vendorid'] == $data2['vendorid']) { ?>
												<td class='text-center'><?=$data2['banyak_vendor']?></td>
											<?php break; } else { ?>
											<?php } ?>
										<?php } ?>
										<td class='text-center'><?= ($data['total_qty']/$data2['banyak_vendor'] > 0 ) ? number_format($data['total_qty']/$data2['banyak_vendor'], 2, '.', '') : 0;?></td>
										</tr>
								<?php } ?>
							</tbody>
						</table>
					</div>

					<div class="col-6 text-center"><p class='mb-0'>&Sigma;PARTS : Total Recplacement Parts</p></div>
					<div class="col-6 text-center"><p class='mb-0'>&Sigma;INST. : Jumlah Alat</p></div>
				</div>
			</div>
		</div>
	</div>

	<!-- Baris 2 (ACTIVITIES BY PRINCIPLE - THIS MONTH) -->
	<div class="col-12">
		<div class="card">
			<div class="card-header">
				<h4 class='text-center fw-bold mt-1'>ACTIVITIES BY PRINCIPLE - THIS MONTH</h4>
			</div> 
			<div class="card-body">

				<div class="row">
					<div class="col-12 col-lg-4 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='4'><h5>TSO - BARAT</h5></th></tr>
								<tr style='text-align: center;'>
									<th style="width:auto;">PRINCIPAL</th>
									<th style="width:15%;">&Sigma; ACT</th>
									<th style="width:18%;">&Sigma; INST.</th>
									<th style="width:10%;">RATIO</th>
								</tr>
							</thead>
							<tbody>
								<?php foreach($act_principle_barat as $data) { ?>
									<?php if($data['vendorname']==null) {continue;} ?>
									<tr>
										<td> <?=$data['vendorname']?> </td>
										<td class='text-center'> <?=$data['banyak_act']?> </td>

										<?php foreach($act_vendor_barat as $data2) { ?>
											<?php if($data['vendorid'] == $data2['vendorid']) { ?>
												<td class='text-center'><?=$data2['banyak_vendor']?></td>
											<?php break; } else { ?>
												
											<?php } ?>
										<?php } ?>
										<td class='text-center'><?= ($data['banyak_act']/$data2['banyak_vendor'] > 0 ) ? number_format($data['banyak_act']/$data2['banyak_vendor'], 2, '.', '') : 0;?></td>
										</tr>
								<?php } ?>
							</tbody>
						</table>
					</div>

					<div class="col-12 col-lg-4 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='4'><h5>TSO - TENGAH</h5></th></tr>
								<tr style='text-align: center;'>
									<th style="width:auto;">PRINCIPAL</th>
									<th style="width:15%;">&Sigma; ACT</th>
									<th style="width:18%;">&Sigma; INST.</th>
									<th style="width:10%;">RATIO</th>
								</tr>
							</thead>
							<tbody>
								<?php foreach($act_principle_tengah as $data) { ?>
									<?php if($data['vendorname']==null) {continue;} ?>
									<tr>
										<td> <?=$data['vendorname']?> </td>
										<td class='text-center'> <?=$data['banyak_act']?> </td>

										<?php foreach($act_vendor_tengah as $data2) { ?>
											<?php if($data['vendorid'] == $data2['vendorid']) { ?>
												<td class='text-center'><?=$data2['banyak_vendor']?></td>
											<?php break; } else { ?>
												
											<?php } ?>
										<?php } ?>
										<td class='text-center'><?= ($data['banyak_act']/$data2['banyak_vendor'] > 0 ) ? number_format($data['banyak_act']/$data2['banyak_vendor'], 2, '.', '') : 0;?></td>
										</tr>
								<?php } ?>
							</tbody>
						</table>
					</div>

					<div class="col-12 col-lg-4 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='4'><h5>TSO - TIMUR</h5></th></tr>
								<tr style='text-align: center;'>
									<th style="width:auto;">PRINCIPAL</th>
									<th style="width:15%;">&Sigma; ACT</th>
									<th style="width:18%;">&Sigma; INST.</th>
									<th style="width:10%;">RATIO</th>
								</tr>
							</thead>
							<tbody>
								<?php foreach($act_principle_timur as $data) { ?>
									<?php if($data['vendorname']==null) {continue;} ?>
									<tr>
										<td> <?=$data['vendorname']?> </td>
										<td class='text-center'> <?=$data['banyak_act']?> </td>

										<?php foreach($act_vendor_timur as $data2) { ?>
											<?php if($data['vendorid'] == $data2['vendorid']) { ?>
												<td class='text-center'><?=$data2['banyak_vendor']?></td>
											<?php break; } else { ?>
												
											<?php } ?>
										<?php } ?>
										<td class='text-center'><?= ($data['banyak_act']/$data2['banyak_vendor'] > 0 ) ? number_format($data['banyak_act']/$data2['banyak_vendor'], 2, '.', '') : 0;?></td>
										</tr>
								<?php } ?>
							</tbody>
						</table>
					</div>

					<div class="col-6 text-center"><p class='mb-0'>&Sigma;ACT : Banyak Activity</p></div>
					<div class="col-6 text-center"><p class='mb-0'>&Sigma;INST. : Jumlah Alat</p></div>
				</div>
			</div>
		</div>
	</div>

	<!-- Baris 3 (TOP 3 SITES WITH INCIDENTS - THIS MONTH) -->
	<div class="col-12">
		<div class="card">
			<div class="card-header">
				<h4 class='text-center fw-bold mt-1'>TOP 3 SITES WITH INCIDENTS - THIS MONTH</h4>
			</div> 
			<div class="card-body">

				<div class="row">
				
					<div class="col-12 col-md-6 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='2'><h5>TSO IT</h5></th></tr>
								<tr style='text-align: center;'>
									<th>SITES</th>
									<th style="width:25%;">&Sigma; IR</th>
								</tr>
							</thead>
							<tbody>
							<?php foreach($incidents_site_tsoit as $data) {?>
									<tr>
										<td><?=$data['sitename']?></td>
										<td class='text-center'><?=$data['total']?></td>
									</tr>
							<?php } ?>
							</tbody>
						</table>
					</div>

					<div class="col-12 col-md-6 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='2'><h5>TSO IVD - TENGAH</h5></th></tr>
								<tr style='text-align: center;'>
									<th>SITES</th>
									<th style="width:25%;">&Sigma; IR</th>
								</tr>
							</thead>
							<tbody>
							<?php foreach($incidents_site_tsotengah as $data) {?>
									<tr>
										<td><?=$data['sitename']?></td>
										<td class='text-center'><?=$data['total']?></td>
									</tr>
							<?php } ?>
							</tbody>
						</table>
					</div>

					<div class="col-12 col-md-6 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='2'><h5>TSO IVD - BARAT</h5></th></tr>
								<tr style='text-align: center;'>
									<th>SITES</th>
									<th style="width:25%;">&Sigma; IR</th>
								</tr>
							</thead>
							<tbody>
							<?php foreach($incidents_site_tsobarat as $data) {?>
									<tr>
										<td><?=$data['sitename']?></td>
										<td class='text-center'><?=$data['total']?></td>
									</tr>
							<?php } ?>
							</tbody>
						</table>
					</div>

					<div class="col-12 col-md-6 mb-2">
						<table class='table small table-bordered'>
							<thead class='table-info'>
								<tr><th class='text-center' colspan='2'><h5>TSO IVD - TIMUR</h5></th></tr>
								<tr style='text-align: center;'>
									<th>SITES</th>
									<th style="width:25%;">&Sigma; IR</th>
								</tr>
							</thead>
							<tbody>
							<?php foreach($incidents_site_tsotimur as $data) {?>
									<tr>
										<td><?=$data['sitename']?></td>
										<td class='text-center'><?=$data['total']?></td>
									</tr>
							<?php } ?>
							</tbody>
						</table>
					</div>
					
				</div>
			</div>
		</div>
	</div>

</div>