<?php $totalServico = 0;
$totalProdutos = 0; ?>
<!DOCTYPE html>
<html lang="pt-br">

<head>
    <title>&nbsp;&#63743; iTecPro - Ordem de Serviço Nº<?php echo $result->idOs ?> de <?php echo $result->nomeCliente ?> </title> 
     <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/bootstrap.min.css" />
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/matrix-style.css" />
    <link href="<?php echo base_url(); ?>assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="<?= base_url('assets/css/custom.css'); ?>" rel="stylesheet">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
  <style>
        .table {
            margin-bottom: 0px;
        }
    .ed {
	font-size: 9px;
}
  </style>
</head>

<body>

    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">

                <div class="invoice-content">
                    <div class="invoice-head" style="margin-bottom: 0">

                        <table class="table table-condensed">
                            <tbody>
                                <?php if ($emitente == null) { ?>

                                    <tr>
                                        <td colspan="3" class="alert">Você precisa configurar os dados do emitente. >>><a href="<?php echo base_url(); ?>index.php/mapos/emitente">Configurar</a>
                                            <<<</td> </tr> <?php } else { ?> 
                                        <td style="width: 25%"><img src=" <?php echo $emitente[0]->url_logo; ?> "></td>
                                        <td> <span style="font-size: 17px;">
                                                &nbsp;&#63743; <?php echo $emitente[0]->nome; ?></span> </br>
                                            <span style="font-size: 12px; ">
                                                <span class="icon">
                                                    <i class="fas fa-fingerprint" style="margin:5px 1px"></i> CNPJ:
                                                    <?php echo $emitente[0]->cnpj; ?> | IE: 0031459540018</br>
                                                    <span class="icon"> 
                                                        <i class="fas fa-map-marker-alt" style="margin:4px 3px"></i>
                                                        <?php echo $emitente[0]->rua . ', nº:' . $emitente[0]->numero . ', ' . $emitente[0]->bairro . ' - ' . $emitente[0]->cidade . ' - ' . $emitente[0]->uf; ?>
                                                    </span> </br> <span>
                                                        <span class="icon">
                                                            <i class="fas fa-comments" style="margin:5px 1px"></i>
                                                            <?php echo $emitente[0]->email . ' - Fone: ' . $emitente[0]->telefone; ?> </br>
                                                            <span class="icon">
                                                                <i class="fas fa-user-check"></i>
                                                                Responsável: <?php echo $result->nome ?>
                                        <td style="width: 18%; text-align: center"><p><span><img src="http://os.itecpro.com.br/application/views/os/qrpix.png" width="104" height="97" alt=""/></span>OS Nº<?php echo $result->idOs ?></p></td>
                                        </span>
                                        </td>
                                    </tr>

                                <?php } ?>
                            </tbody>
                        </table>
                        <table width="661"  class="table table-condensend">
                            <tbody>
                                <tr>
                                    <td width="94%"  style="width: 100%; padding-left: 0">
                                        <ul>
                                            <li><i class="fas fa-users"></i>:<?php echo $result->nomeCliente ?> - <i class="fas fa-address-card" style="margin:5px 1px"></i></b>:<?php echo $result-> documento ?> - <i class="fas fa-phone-square"></i>:<?php echo $result-> celular_cliente ?><span> <?php echo $result->rua ?> <?php echo $result->numero ?> </span><span><?php echo $result->bairro ?> <?php echo $result->cidade ?> <?php echo $result->estado ?></span><br>
                                          </li>
                                        </ul>
                                    </td>

                                    <?php if ($qrCode): ?>
                                        <td width="6%" style="width: 15%; padding-left: 0">&nbsp;</td>
                                    <?php endif ?>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div style="margin-top: 0; padding-top: 0">
                        <table width="678" class="table table-condensed">
                            <tbody>

                                <?php if ($result->dataInicial != null) { ?>
                                    <tr>
                                        <td width="164">
                                            <b>Status:</b> <?php echo $result->status ?>
                                        </td>

                                        <td width="163">
                                            <b>Entrada:</b> <?php echo date('d/m/Y', strtotime($result->dataInicial)); ?>
                                        </td>

                                        <td width="135">
                                            <b>Saída: </b><?php echo $result->dataFinal ? date('d/m/Y', strtotime($result->dataFinal)) : ''; ?>
                                        </td>

                                        <td width="196">
                                            <b>Garantia: </b>
                                            <?php echo $result->garantia . ' dias'; ?>
                                        </td>

                                        
									<tr>	
								<?php }?>
								<?php if($result->equipamento != null){?>
                                <td>
                                <b>Equipamento: </b><?php echo $result->marca; ?>
                                </td>
                                
                                <td>
                                <b>Modelo:</b> <?php echo $result->modelos; ?></td>
								<?php }?>
								<?php if($result->marca != null){?>
                              
								<?php }?>
								<?php if($result->modelo != null){?>
                                <td>
                                <b>Cor:</b> <?php echo $result->equipamento; ?></td>
								
								<?php }?>
								<?php if($result->nr_serie != null){?>
								<td><b>ID: </b><?php echo $result->nr_serie; ?>
                                </td>

                            </tr>
						
							
							
                                <?php } ?>

                                <?php if ($result->descricaoProduto != null) { ?>
                                   
                                <?php } ?>

                                <?php if ($result->defeito != null) { ?>
                                    <tr>
                                        <td colspan="5">
                                            <b>Defeito Apresentado: </b>
                                            <?php echo htmlspecialchars_decode($result->defeito) ?> / <b>Deu entrada ligado?</b> <?php echo htmlspecialchars_decode($result->ligaS== 1) ? 'Sim' : '' ?><?php echo htmlspecialchars_decode($result->ligaN== 1) ? 'Não' : '' ?> / <b>Deu entrada com algum quebrado?</b> <?php echo htmlspecialchars_decode($result->quebraN== 1) ? 'Não' : '' ?><?php echo htmlspecialchars_decode($result->quebraS== 1) ? 'Sim' : '' ?></td>
                                    </tr>
									
								
							
							      
                                <?php } ?>
							
                                <?php if ($result->observacoes != null) { ?>
                                    <tr>
                                        <td colspan="5">
                                            <b>Laudo Técnico: </b>
                                            <?php echo htmlspecialchars_decode($result->observacoes) ?>
                                        </td>
                                    </tr>
                                <?php } ?>

                                <?php if ($result->laudoTecnico != null) { ?>
                                    <tr>
                                        <td height="21" colspan="5">
                                            <b>Serviço Realizado: </b>
                                            <?php echo htmlspecialchars_decode($result->laudoTecnico) ?>
                                        </td>
                                    </tr>
                                <?php } ?>
                            </tbody>
                        </table>

                        <p>
                          <?php if ($produtos != null) { ?>
                       </p>
                        <table class="table table-bordered table-condensed" id="tblProdutos">
                                <thead>
                                    <tr>
                                        <th width="288">Produto</th>
                                        <th width="19">&nbsp;</th>
                                        <th width="43">Unit.</th>
                                        <th width="86">Total</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php

                                    foreach ($produtos as $p) {
                                        $totalProdutos = $totalProdutos + $p->subTotal;
                                        echo '<tr>';
                                        echo '<td>' . $p->descricao . '</td>';
                                        echo '<td>' . $p->quantidade . '</td>';
                                        echo '<td>' . $p->preco ?: $p->precoVenda . '</td>';

                                        echo '<td>R$ ' . number_format($p->subTotal, 2, ',', '.') . '</td>';
                                        echo '</tr>';
                                    } ?>

                                    <tr>
                                        <td></td>
                                        <td colspan="2" style="text-align: right"><strong>Total:</strong></td>
                                        <td><strong>R$ <?php echo number_format($totalProdutos, 2, ',', '.'); ?></strong></td>
                                    </tr>
                                </tbody>
                            </table>
                        <?php } ?>

                        <?php if ($servicos != null) { ?>
                            <table class="table table-bordered table-condensed">
                                <thead>
                                    <tr>
                                        <th width="288">Serviço</th>
                                        <th width="18">&nbsp;</th>
                                        <th width="46"> Unit.</th>
                                        <th width="98">Total</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    setlocale(LC_MONETARY, 'en_US');
                                    foreach ($servicos as $s) {
                                        $preco = $s->preco ?: $s->precoVenda;
                                        $subtotal = $preco * ($s->quantidade ?: 1);
                                        $totalServico = $totalServico + $subtotal;
                                        echo '<tr>';
                                        echo '<td>' . $s->nome . '</td>';
                                        echo '<td>' . ($s->quantidade ?: 1) . '</td>';
                                        echo '<td>' . $preco . '</td>';
                                        echo '<td>R$ ' . number_format($subtotal, 2, ',', '.') . '</td>';
                                        echo '</tr>';
                                    } ?>

                                    <tr>
                                        <td colspan="3" style="text-align: right"><strong>Total:</strong></td>
                                        <td><strong>R$ <?php echo number_format($totalServico, 2, ',', '.'); ?></strong></td>
                                    </tr>
                                </tbody>
                            </table>
                              <?php } ?>
                              <?php
                        if ($totalProdutos != 0 || $totalServico != 0) {
                            echo "<h4 style='text-align: right'> Valor Total da OS: R$" . number_format($totalProdutos + $totalServico, 2, ',', '.') . "</h4>";
                        }

                        ?>
            <center>
</p><p><img src="http://os.itecpro.com.br/application/views/os/qrgarantia.jpeg" width="803" height="144" alt=""/></p></div>
</div>
            </div>
        </div>
    </div>



    <script src="<?php echo base_url(); ?>assets/js/bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/matrix.js"></script>

    <script>
        window.print();
    </script>
      <footer class="footer"><div align=center>
        <p><a href='Autenticador'><img src='https://contador.s12.com.br/img-7156dZZyzdYZA9AD-57.gif' border='0' alt='contador grátis'></a>
        <script type='text/javascript' src=''></script></p>
      </div>
</p></footer>

</body>

</html>
