<!doctype html>
<html lang="es">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="description" content="Ventas.">
        <meta name="author" content="Edu FX">

        <title><?php echo !empty($title) ? $title : 'Ventas DeMente Games: ';?></title>

        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/solid.css" integrity="sha384-ioUrHig76ITq4aEJ67dHzTvqjsAP/7IzgwE7lgJcg2r7BRNGYSK0LwSmROzYtgzs" crossorigin="anonymous">
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/fontawesome.css" integrity="sha384-sri+NftO+0hcisDKgr287Y/1LVnInHJ1l+XC7+FOabmTTIK0HnE2ID+xxvJ21c5J" crossorigin="anonymous">

        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/jquery-ui.css">
        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/style.css">
        <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/print.css"/>

        <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>

		<style>
			/* ===== SOLO PARA IMPRESIÓN DE TRASPASOS ===== */

			.print-traspaso {
				font-size: 17px;
			}

			.print-traspaso h5 {
				font-size: 21px;
				font-weight: 700;
			}

			.print-traspaso table th {
				color: #000;
				font-size: 20px;
				padding: 10px 6px;
			}

			.print-traspaso table td {
				color: #000;
				font-size: 20px;
				padding: 6px 6px;
				vertical-align: middle;
				font-weight: 700;
			}

			.print-traspaso .print-box {
				display: inline-block;
				width: 90px;
				height: 40px;
				border: 2px solid #000;
			}

			.print-recepcion {
				color: #000;
				-webkit-print-color-adjust: exact;
				print-color-adjust: exact;
			}

		</style>
    </head>
    <body>
        <div class="container print-traspaso">
            <?php
                if (!empty($traspaso)) {
                    $t = $traspaso;

					$estado = (int)$t['estado_traspaso'];
					$preparado_listo = ($estado >= 3);   // Preparado o completado
					$recibido_listo  = ($estado >= 4);   // Completado

                    ?>
                    <div class="row mt-5">
                        <div class="col">
                            <h5>Traspaso #<?php echo $t['id']; ?></h5>
                        </div>
                        <div class="col">
                            <h5>Solicitante: <?php echo $usuarios[$t['id_solicitante']]; ?></h5>
                        </div>
                        <div class="col">
                            <h5>Origen: <?php echo $almacenes[$t['id_origen']]; ?></h5>
                        </div>
                        <div class="col">
                            <h5>Destino: <?php echo $almacenes[$t['id_destino']]; ?></h5>
                        </div>
                    </div>

                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th scope="col">Producto</th>
                            <th scope="col" class="text-center">D. Origen</th>
                            <th scope="col" class="text-center">D. Destino</th>
                            <th scope="col" class="text-center">Solicitado</th>
                            <th scope="col" class="text-center">Preparado</th>
                            <th scope="col" class="text-center">Recibido</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
                            foreach ($t['productos_traspasos'] as $tp) {
                                ?>
                                <tr>
                                    <td class=""><?php echo $productos[$tp['id_producto']]; ?></th>
                                    <td class="text-center"><?php echo $info_productos[$tp['id_producto']][$t['id_origen']]['disponibles']; ?></td>
                                    <td class="text-center"><?php echo $info_productos[$tp['id_producto']][$t['id_destino']]['disponibles']; ?></td>
                                    <td class="text-center"><?php echo $tp['solicitado']; ?></td>
                                    <td class="text-center">
										<?php if ($preparado_listo): ?>
											<?php echo $tp['preparado']; ?>
										<?php else: ?>
											<span class="print-box"></span>
										<?php endif; ?>
									</td>
									<td class="text-center">
										<?php if ($recibido_listo): ?>
											<?php echo $tp['recibido']; ?>
										<?php else: ?>
											<span class="print-box"></span>
										<?php endif; ?>
									</td>
                                </tr>
                                <?php
                                }
                            ?>
                        </tbody>
                    </table>
                    <?php
                }
            ?>
        </div>
        <script src="<?php echo base_url(); ?>js/jquery-ui.min.js"></script>
        <script src="<?php echo base_url(); ?>js/functions.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    </body>
</html>