<!DOCTYPE html>
<html lang="en">
  	<head>
    	<meta charset="utf-8">
    	<title>Fatura para pagamento</title>
    	<?php echo $__env->make('pdfs.css-style', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
  	</head>
  	<body>
  		<!-- inicio header-->
	    <div id="header" class="clearfix">
	      	<div id="logo"></div>

	      	<div id="empresa">
	        	<h2 class="nome">TW Solutions</h2>
		        <div>Av. Emílio Ribas, 1056 - Jardim Vila Galvão - Guarulhos, SP</div>
		        <div>(11) 3230-1933</div>
		        <div><a href="mailto:financeiro@twsolutions.com.br">financeiro@twsolutions.com.br</a></div>
	      	</div>
	    </div>
	    <!-- fim header-->	
    	
    	<div id="main" class="clearfix">
	      	<div id="detalhes">
		        <div id="cliente">
	    	    	<div class="para">CLIENTE:</div><br>
	          		<h2 class="nome"><?php echo e($customer->name); ?></h2>
	           		<div class="para"><strong>Número da conta:</strong> <?php echo e($fat->ordered_id); ?></div>
	          		<div class="address"><?php echo e($customer->address); ?>, <?php echo e($customer->number); ?> - <?php echo e($customer->neighborhood); ?></div>
	          		<div class="email"><?php echo e($customer->email); ?></div>
	          		<div class="email"><?php echo e($customer->city); ?> – <?php echo e($customer->state); ?> – CEP: <?php echo e($customer->zip_code); ?></div>
	        	</div>
	      	</div>
	      	<div id="invoice">
          		<h1>FATURA PARA PAGAMENTO</h1>
          		<div class="date">Data de Emissão: <?php echo e(dateToBR($fat->data_faturamento)); ?></div>
          		<div class="date">Data de Vencimento: <?php echo e(dateToBR($fat->data_vencimento)); ?></div>
          		<div class="date">Período: <?php echo e($periodo); ?></div>
          		<div class="date">Mês de Referência: <?php echo e($mes_referencia); ?></div>
        	</div>
	    </div>

		 <div id="main" class="clearfix">
	      	<table border="0" cellspacing="0" cellpadding="0" class="fatura">
          		<?php if(isset($itens['servicos'])): ?>
          			<tr>
	            		<th colspan="5" class="unit title">Serviços Contratados</th>
	            		<th class="total">Valor(R$)</th>
	          		</tr>
          			<?php foreach($itens['servicos'] as $servico): ?>
          				<tr>
		            		<td colspan="5" class="border-bottom border-left"><?php echo e($servico['descricao']); ?></td>
		            		<td class="border-bottom border-right"><?php echo e(financialPrice($servico['valor'])); ?></td>
		          		</tr>
          			<?php endforeach; ?>
          			<tr>
	            		<td colspan="6">&nbsp;</th>
	          		</tr>
          		<?php endif; ?>

          		<?php if(isset($itens['franquia_local']) or isset($itens['franquia_aberta'])): ?>
          			<tr>
	            		<th colspan="5" class="unit title">Franquias do plano</th>
	            		<th class="unit title">&nbsp;</th>
	          		</tr>
	          		<tr>
	            		<th class="border-left border_bottom" colspan="4">&nbsp;</th>
	            		<th class="total border_bottom">Contratado</th>
	            		<th class="total border_bottom">Utilizado</th>
	          		</tr>
	          		<?php if(strlen($itens['franquia_local'])): ?>
		          		<tr>
		            		<td class="border-left border-bottom" colspan="4">Fixo Local</td>
		            		<td class="border-bottom"><?php echo e($franquia['LocalContratada']); ?></td>
		            		<td class="border-right border-bottom"><?php echo e($franquia['LocalUtilizada']); ?></td>
		          		</tr>
	          		<?php endif; ?>
	          		<?php if(strlen($itens['franquia_aberta'])): ?>
		          		<tr>
		            		<td class="border-left border-bottom" colspan="4">Franquia de voz (Aberta)</td>
		            		<td class="border-bottom"><?php echo e($franquia['AbertaContratada']); ?></td>
		            		<td class="border-right border-bottom"><?php echo e($franquia['AbertaUtilizada']); ?></td>
		          		</tr>
	          		<?php endif; ?>
	          		<tr>
	            		<td colspan="6">&nbsp;</th>
	          		</tr>
          		<?php endif; ?>

          		<?php if(isset($itens['produtos'])): ?>
          			<tr>
	            		<th class="unit title" colspan="5">Produtos</th>
	            		<th class="total">Valor(R$)</th>
	          		</tr>
          			<?php foreach($itens['produtos'] as $produto): ?>
          				<tr>
		            		<td class="border-left border-bottom" colspan="5"><?php echo e($produto['descricao']); ?></td>
		            		<td class="border-right border-bottom">(+) <?php echo e(financialPrice($produto['valor'])); ?></td>
		          		</tr>
          			<?php endforeach; ?>
          			<tr>
	            		<td colspan="6">&nbsp;</th>
	          		</tr>
          		<?php endif; ?>

          		<?php if(isset($fixoLocal) or isset($fixoLdn) or isset($movelLocal) or isset($moveInterurbano) or isset($franquia0800) or isset($franquia4000)): ?>
	          		<tr>
	            		<th colspan="5" class="unit title">Resumo de Consumo</th>
	            		<th class="unit title">&nbsp;</th>
	          		</tr>
	          		<tr>
	          			<th class="border-left"colspan="3">&nbsp;</th>
	            		<th class="unit">Total de Horas</th>
	            		<th class="unit">Total de Minutos</th>
	            		<th class="total">Valor(R$)</th>
	          		</tr>
	          		<?php if(count($fixoLocal) > 0): ?>
	          			<tr>
		          			<td class="border-left border-top" colspan="3">Fixo Local</td>
		            		<td class="border-left"><?php echo e($fixoLocal['horas']); ?></td>
		            		<td class="border-left"><?php echo e($fixoLocal['minutos']); ?></td>
		            		<td class="border-right border-left"><?php echo e($fixoLocal['valor']); ?></td>
		          		</tr>
	          		<?php endif; ?>

	          		<?php if(count($fixoLdn) > 0): ?>
	          			<tr>
		          			<td class="border-left" colspan="3">Fixo LDN</td>
		            		<td class="border-left"><?php echo e($fixoLdn['horas']); ?></td>
		            		<td class="border-left"><?php echo e($fixoLdn['minutos']); ?></td>
		            		<td class="border-right border-left"><?php echo e($fixoLdn['valor']); ?></td>
		          		</tr>
	          		<?php endif; ?>

	          		<?php if(count($movelLocal) > 0): ?>
	          			<tr>
		          			<td class="border-left" colspan="3">Móvel Local</td>
		            		<td class="border-left"><?php echo e($movelLocal['horas']); ?></td>
		            		<td class="border-left"><?php echo e($movelLocal['minutos']); ?></td>
		            		<td class="border-right border-left"><?php echo e($movelLocal['valor']); ?></td>
		          		</tr>
	          		<?php endif; ?>

	          		<?php if(count($moveInterurbano) > 0): ?>
	          			<tr>
		          			<td class="border-left border-bottom" colspan="3">Móvel Interurbano</td>
		            		<td class="border-left border-bottom"><?php echo e($moveInterurbano['horas']); ?></td>
		            		<td class="border-left border-bottom"><?php echo e($moveInterurbano['minutos']); ?></td>
		            		<td class="border-right border-bottom"><?php echo e($moveInterurbano['valor']); ?></td>
		          		</tr>
	          		<?php endif; ?>
					
					<?php if(count($franquia0800) > 0): ?>
	          			<tr>
		          			<td class="border-left border-bottom" colspan="3">0800</td>
		            		<td class="border-left border-bottom"><?php echo e($franquia0800['horas']); ?></td>
		            		<td class="border-left border-bottom"><?php echo e($franquia0800['minutos']); ?></td>
		            		<td class="border-right border-bottom"><?php echo e($franquia0800['valor']); ?></td>
		          		</tr>
	          		<?php endif; ?>
					
					<?php if(count($franquia4000) > 0): ?>
	          			<tr>
		          			<td class="border-left border-bottom" colspan="3">40XX</td>
		            		<td class="border-left border-bottom"><?php echo e($franquia4000['horas']); ?></td>
		            		<td class="border-left border-bottom"><?php echo e($franquia4000['minutos']); ?></td>
		            		<td class="border-right border-bottom"><?php echo e($franquia4000['valor']); ?></td>
		          		</tr>
	          		<?php endif; ?>
          		<?php endif; ?>
          		<tfoot>
	        		<tr>
	            		<td colspan="6">&nbsp;</td>
	          		</tr>
	          		<tr>
	            		<td colspan="3"></td>
	            		<td colspan="2">TOTAL A PAGAR</td>
	            		<td><?php echo e($total); ?></td>
	          		</tr>
	        	</tfoot>
	      	</table>
	      	<?php if(!empty($numbers)): ?>
		      	<br>
		      	<table border="0" cellspacing="0" cellpadding="0" class="fatura">
			        <thead>
		          		<tr>
		            		<th colspan='5' class="total">NÚMEROS CONTRATADOS</th>
		          		</tr>
		        	</thead>
		        	<tbody>
		        		<tr>
		        		<?php foreach($numbers as $key => $number): ?>	
			            	<td class="desc"><h3><?php echo e($number->servico); ?></h3></td>
			          		<?php if( (($key+1)%5)==0): ?>
								</tr>
								<tr>
			          		<?php endif; ?>
			          	<?php endforeach; ?>
			          	</tr>
		        	</tbody>
		      	</table>
		      	<br>
		    <?php endif; ?>
		    
	       	<div id="codigodebarras">
	       		<center>
	       			<?php if($fat->invoice_id): ?>
	       				<?php echo e($linhaDigitavel); ?> <br/>
	       				<?php echo $codigoDeBarras; ?>

	       			<?php endif; ?>
	       		</center>
	       	</div>

	       	<br><br><br><br><br><br><br><br>

	       	<?php /*

          	<?php if(isset($itens['ligacoes'])): ?>
          		<center><h1>Detalhamento de Fatura</h1><center>
          		<table border="0" cellspacing="0" cellpadding="0" class="fatura">
	          		<?php foreach($itens['ligacoes'] as $key => $tipagens): ?>
		          		<?php foreach($tipagens as $tipagem => $ligacoes): ?>
		          			<tr>
			            		<td colspan=6><h2>Consumo <?php echo e($tipagem); ?><h2></td>
			          		</tr>
			          		<tr>
			            		<th class="unit">Data</th>
			            		<th class="unit">Origem</th>
			            		<th class="unit">Destino</th>
			            		<th class="unit">Tipo</th>
			            		<th class="unit">Duração</th>
			            		<th class="total">Valor</th>
			          		</tr>
		          			<?php foreach($ligacoes as $ligacao): ?>
		          				<?php if($tipagem == $ligacao['tipagem']): ?>
				          			<tr>
					            		<td class="border-left border-bottom"><?php echo e($ligacao['dataHora']); ?></td>
					            		<td class="border-bottom"><?php echo e($ligacao['origem']); ?></td>
					            		<td class="border-bottom"><?php echo e(str_replace(' ','',$ligacao['destino'])); ?></td>
					            		<td class="border-bottom"><?php echo e($ligacao['tipo']); ?></td>
					            		<td class="border-bottom" style="align:center"><?php echo e($ligacao['duracao']); ?></td>
					            		<td class="border-right border-bottom" style="align:right"><?php echo e($ligacao['valor']); ?></td>
					          		</tr>
					          	<?php endif; ?>
				          	<?php endforeach; ?>
		          		<?php endforeach; ?>
	          		<?php endforeach; ?>
	          	</table>
	        <?php endif; ?>

	        */ ?>
	        	
	      	<div id="thanks">Atenciosamente,<br>TW Solutions</div>

	      	<div id="notices">
	        	<div>MENSAGEM PARA VOCÊ:</div>
	        	<div class="notice">Ajude o meio ambiente. Opte por receber suas faturas e extratos por e-mail. Pague contas usando o número do código de barras. Você pode salvar o comprovante digitalmente também.</div>        
	      	</div>
	      	
	    </div>
  	</body>
</html>