<!DOCTYPE html>
<html>
<head>
	<title>Marker</title>
	<style type="text/css">
		body {
            margin: 0;
            padding: 0;
            width: 4.6cm;
			height: 3.2cm;
			overflow: hidden;
			/*border: 1px solid black;*/
			font-family: 'helvetica';
			font-size: 8px
			box-sizing: border-box;
		}
	    table {
            width: 110%;
            height: 100%; /* Sesuaikan dengan tinggi body */
        
            border-collapse: collapse;
        }

        tr, td {
            height: auto; /* Tinggi otomatis */
            overflow: hidden;
            box-sizing: border-box;
            border: 1px solid #000; /* Border sel - INI PENTING! */
            padding: 1px; /* Tambahkan padding agar tidak mepet */
        }
	    .tr-note td.lbl{
			font-size: 6px;
		}

		.ico-arrow {
			position: absolute;
			top: 7px;
			right: 0px;
			height: 23px;
		}
		/* Style untuk teks vertikal */
        .vertical-text {
            writing-mode: vertical-rl;
            text-orientation: mixed;
            font-size: 8px;
            font-weight: bold;
            letter-spacing: 2px;
            padding: 2px 0;
        }
        .qr-container {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 2px;
        }

	</style>
	<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/jquery/jquery.min.js"></script>
</head>
<body onload="window.print();">
 <table style="border-collapse: collapse;border: 1px solid #000;" border="1" cellpadding="1" width="100%">
		<?php 
			$tot = count($trx);
			$txt = '';
			
			foreach ($trx as $key => $value) {
				$is_row = false;
				$lspan = 3;
				if (strlen($value['trx_note']) > 0) {
					$is_row = true;
					$lspan = 4;
				}
				$is_row_cost = false;
				if (count($value['arr_cost']) > 0) {
					$is_row_cost = true;
					$lspan++;
				}
		?>
			<tr>
			    <!--<td rowspan="<?php echo $lspan;?>" width="70px">
			        <br>-->
				    <!--<div align="center"style="font-size: 10px;font-weight:bold;"><?php echo ''. $value['item_code'];?></div>-->
				   <!-- <div align="center"style="font-size: 12px;font-weight:bold;text-align:center;"><?php echo ' Stopwash ';?></div>
				  <img style="display:inline-block" src="https://quickchart.io/qr?size=70&text=<?php echo $value['item_code'];?>">
			        <div align="center"style="font-size: 10px;font-weight:bold;text-align:center;"><?php echo ($key + 1).'/'.$tot;?></div>
			       <div align="center"style="font-size: 10px;font-weight:bold;text-align:center;"><?php echo $outlet['outlet_name'];?></div>
			       <!--div align="center"style="font-size: 10px;text-align:center;"><?php echo''.Date('d M H:i', strtotime ($data['duedate']));?>
			    </td>-->
				<td colspan="2"
				<br>
				<br>
					<div style="font-size:12px;font-weight:bold;text-align:center;margin-bottom: 6px;">
					   <?php $nama = $data['customer_name'];$nama = ucwords(strtolower($nama)); // Buat setiap awal kata kapital
                           echo strlen($nama) > 17 ? substr($nama, 0, 17) . '...' : $nama;?>
					</div>
					<div style="font-size:12px;font-weight:bold;text-align:center;">
				    <?php echo substr((string) $data['code'], -5).' - ' .$outlet['outlet_name'];?>
				    </div>
				</td>
				   <td rowspan="<?php echo $lspan;?>" width="70px">
			        <br>
				      <div align="center"style="font-size: 12px;font-weight:bold;text-align:center;">
				        <?php echo ' Stopwash ';?></div>
				     <div align="center"style="font-size: 10px;font-weight:bold;text-align:center;margin-bottom: 8px;"><?php echo $outlet['outlet_name'];?></div>
				     <!--<img style="display:inline-block" src="https://quickchart.io/qr?size=70&text=<?php echo $value['item_code'];?>">-->
			        <div align="center" style="font-size: 10px;text-align:center;font-weight:bold;">
                          <?php $nama = $data['customer_name'];$nama = ucwords(strtolower($nama)); // Buat setiap awal kata kapital
                           echo strlen($nama) > 11 ? substr($nama, 0, 11) .'-' : $nama;?><br>
                           <?php echo substr($value['product_name'], 0, 12); ?>
                    </div>
			        <div align="center" style="font-size: 12px;font-weight:bold;text-align:center;margin-bottom: 5px;">
                                <?php echo ($key + 1).'/'.$tot.'-'. substr((string) $data['code'], -5); ?>
                    </div>
			         <!--<div align="center"style="font-size: 10px;font-weight:bold;text-align:center;"><?php echo ($key + 1).'/'.$tot;?></div>
			             <div align="center"style="font-size: 10px;font-weight:bold;text-align:center;"><?php echo $outlet['outlet_name'];?></div>-->
			        <div colspan="2"style="font-size: 10px;text-align:center;font-weight:bold;min-height: 30px">
			            <?php echo substr($value['trx_note'], 0, 20); ?></div>
			    </td>
			</tr>
			<tr>
				<td style="width: 20px!important; font-size: 16px; text-align: center; font-weight: bold;">
					<?php echo ($key + 1).'/'.$tot;?>
				</td>
				<td style="font-size: 10px;text-align:center;font-weight:bold;">
				    <br>
				      <?php echo substr($value['product_name'], 0, 12); ?><br>
				    <?php echo''.Date('d M H:i', strtotime ($data['duedate']));?>
				</td>
		   </tr>
			<tr>
				<td colspan="2"style="font-size: 11px;text-align:center;font-weight:bold;">
				    <?php echo $value['colour'].', '.$value['hue'].', '.$value['spot'];?><br><br>
				</td>
			</tr>
			<?php
				if ($is_row) {
			?>
			<tr>
				 <!--<td colspan="2"style="font-size: 10px;font-weight:bold;"><?php echo $value['trx_note'];?></td>-->
			</tr>
			<?php
				}
			?>
			<?php
				if (($is_row_cost)) {
					$txt_cost = '';
					foreach ($value['arr_cost'] as $c_key => $c_value) {
						$comma = ', +';
						if ($c_key == 0) {
							$comma = '+';
						}
						$txt_cost .= $comma.$c_value['name'];
					}
			?>
			
				<td colspan="2"><?php echo $txt_cost;?></td>
		    </tr>
		    <?php
				}
			?>
			</tr>
			<tr>
			    <!--<td align="center"style="font-size: 8px;font-weight:bold;"><?php echo''.Date('d M H:i', strtotime ($data['duedate']));?></td>
			    <td align="center"><?php echo $outlet['outlet_name'];?></td>
				<td colspan="1">
					<div style="font-size:12px;">-->
					
					<!--<?php echo $value['item_code'].',<br>klr: '.Date('d M (H:i)', strtotime($data['duedate']));?>-->
					</div>
				</td>
			</tr>
			<?php
			}
		?>
	</table>
</body>
</html>