Ir para conteúdo
Fórum Script Brasil
  • 0

Impressão Windows.Print() com o mesmo layout da pagina


7master

Pergunta

Olá pessoal, estou tentando imprimir usando o código:

<body onLoad="javascript: printPage();">

Porém, quando visualizo a pagina para impressão ele não carrega a formatação atual da página, existe alguma forma de carregar?

 

Código da Página

<?php
	header("Content-Type: text/html; charset=utf8", true);

	include_once("conmysql.php");

	session_start();
	// include_once("seguranca.php");
	include_once("funcoes.php");
  



setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');

function after ($this, $inthat)
    {
        if (!is_bool(strpos($inthat, $this)))
        return substr($inthat, strpos($inthat,$this)+strlen($this));
    };

function before ($this, $inthat)
    {
        return substr($inthat, 0, strpos($inthat, $this));
    }; 




 function GetDadosPassagem($ID=0){

 	 $EditPAS_ID = $ID;
 	 // print_r($ID);
 	 // var_dump($ID);


 }

   $id = $_GET['id'];

   $id_print = $_GET['id'];

   $id_ida = before (',',$id );

   $id_volta = after (',',$id );

   $parte = explode(",", $id);

   $Qtde_Oficio = count(array_keys($parte)) ;
   $Qtde_Oficio = $Qtde_Oficio -1;



  $qry_master = "SELECT 
					S.SOL_ID,
					S.OFICIO,
					concat(S.SOL_ID,concat('-', lpad(S.NUMERO, 3, '0'),'/'),DATE_FORMAT(S.DATA_CAD,'%Y')) AS OFICIO_FORMATADO ,
					P.ORIGEM,
					P.DESTINO,
					S.NUMERO,
					DATE_FORMAT(S.DATA_CAD,'%d/%m/%Y') as DATA_CAD,
					U.ORG_ID,
					O.ORG_RAZAO,
					U.USU_NOME,
					U.USU_EMAIL,
					U.USU_TELEFONE,
					U.PERF_ID,
					CASE S.TIPO_SERVICO  
					 WHEN 'C' THEN 'CONVECIONAL' 
					 WHEN 'E' THEN 'EXECUTIVO' 
					 WHEN 'L' THEN 'LEITO'
					END AS TIPO_SERVICO,
                    E.EMP_FANTASIA,	
                    O.ORG_LOG, 
					S.STATUS,				
					S.OBS,
					(SELECT COUNT(PASSAGENS.SOL_ID) FROM PASSAGENS WHERE PASSAGENS.SOL_ID = S.SOL_ID) AS QTDE_PASSAGEM						  
				  FROM
					SOLICITACOES S	
					INNER JOIN PASSAGENS P ON (S.SOL_ID = P.SOL_ID)					  
					INNER JOIN ORGAOS    O ON (S.ORG_ID = O.ORG_ID)
					INNER JOIN USUARIOS  U ON (S.USU_ID = U.USU_ID)
                    INNER JOIN EMPRESAS  E ON (S.EMP_ID = E.EMP_ID)
				WHERE S.SOL_ID  in( ".$id.")
				ORDER BY S.SOL_ID DESC ";
		
    
	if ($resultado = mysqli_query($con,$qry_master)){

		 $QTDE_TOTAL_PASSAGEM = mysqli_num_rows($resultado);
          while ($registro = $resultado->fetch_object()) {
           
          	$SOL_ID         = $registro->SOL_ID;
	 	  	$USU_NOME       = $registro->USU_NOME;
	 	  	$USU_EMAIL      = $registro->USU_EMAIL;
	 	  	$USU_TELEFONE   = $registro->USU_TELEFONE;
	 	  	$NUMERO         = $registro->NUMERO;
	 	  	$OFICIO         = $registro->OFICIO_FORMATADO;

	 	  	$ORG_ID         = $registro->ORG_ID;
	 	  	$ORG_RAZAO      = $registro->ORG_RAZAO;
	 	  	$PERF_ID        = $registro->PERF_ID;
	 	  	$STATUS         = $registro->STATUS;
	 	  	$EMP_FANTASIA   = $registro->EMP_FANTASIA;
	 	  	// $QTDE_PASSAGEM  = $registro->QTDE_PASSAGEM;
	 	  	$ORIGEM         = $registro->ORIGEM;
	 	  	$ORG_LOG        = $registro->ORG_LOG;
	 	  	$OBS            = $registro->OBS;
	 	  }

     }


     // pegando os gestores do orgão e adicionando os
	$SQL_Gestor = "SELECT 
					  USUARIOS.USU_ID,
					  USUARIOS.USU_NOME,
					  USUARIOS.USU_EMAIL,
					  USUARIOS.USU_TELEFONE
					FROM
					  USUARIOS
					  INNER JOIN PERFIL ON (USUARIOS.PERF_ID = PERFIL.PERF_ID)
					WHERE
					  USUARIOS.PERF_ID = 3 AND
					  USUARIOS.ORG_ID = ".$ORG_ID;

	if ($resul_gestor=mysqli_query($con,$SQL_Gestor)){
		 while ($lin=mysqli_fetch_assoc($resul_gestor)){ 
		 	$GESTOR_NOME = utf8_decode($lin['USU_NOME']);
		 	$GESTOR_TELEFONE = utf8_decode($lin['USU_TELEFONE']);
		 	$GESTOR_EMAIL = utf8_decode($lin['USU_EMAIL']);
		 	
		 }
	}

   
?>

<!DOCTYPE html>
<html lang="pt-br">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title></title> 
      <link rel="shortcut icon" type="image/png" href="img/favicon.ico"/> 
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" > 
	  <link href="http://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet" type="text/css">
	  <link rel="stylesheet" href="css/font-awesome.min.css" >
	  <link href="css/solicitacoes.css" rel="stylesheet" >        
	  <link href="css/painel.css" rel="stylesheet" >	

	  <style type="text/css">
        	body{
        		margin: 0;
        		padding: 0;
        		font-size: small !important;
        		background: #FFF;
        	}
        	h3{font-size:16px; font-weight: bold;}

        

        </style>	
	  
</head>
<body onLoad="javascript: printPage();">    
	
      

<div class="topo text-right" style="font-size:10px; margin-right:5px; color:666;">
	
	<?php
		date_default_timezone_set('America/Sao_Paulo');
		$date = date('d/m/Y H:i');
		echo 'Data da Impressão: '. $date.' - Usuário: '. $_SESSION['usuario_nome'];
	?>
	</div>

</div>
<!-- <div class="rodape">RODAPE</div> -->

		

	
	  <div class="panel-body" >
	    <div class="col-xs-12" >	
		 
	     
		  <div class="row">
		  	
			<div class="pull-left">
				<img width="160" height="70" src="<?php echo "/logo-orgaos/".$ORG_LOG; ?>" alt="">		
			</div> 	
		
		
			<div class="pull-right">
				<h3><?php echo utf8_encode($ORG_RAZAO); ?></h3>		
			</div> 
	
			<div class="row">
			   <p>&nbsp;</p>
			   
			   <p>&nbsp;</p>
			   <p>&nbsp;</p>
			   <p>&nbsp;</p>
			</div>
			
			<div class="row-fluid">
				<div class="pull-left">
					<strong>Ofício nº <?php echo $OFICIO; ?></strong>	
				</div> 	
				<div class="pull-right">
					<p><?php echo utf8_encode($USU_NOME); ?>, <?php echo utf8_encode(strftime('%A, %d de %B de %Y', strtotime('today'))); ?></p>		
				</div> 
			</div>
			
			<p>&nbsp;</p>
			  
			   
			
			<div class="row-fluid text-left">
				<p>A Maracanãs Viagens e Turismo:</p>	
				<p>Solicitamos a compra de passagens rodoviárias em favor de nossos servidores, conforme relacionado abaixo:</p>	
			</div> 	
			
			<p>&nbsp;</p>
			<?php

			   $qtde_trecho = sizeof($parte) - 1;

				for ($i=0; $i < $qtde_trecho; $i++){ 

					$id = $parte[$i];

   	  
  
  
					   $qry = "SELECT 
									S.SOL_ID,
									S.OFICIO,
									S.NUMERO,
									DATE_FORMAT(P.DATA_EMBARQUE,'%d/%m/%Y' ) as DATA_EMBARQUE,
								 	DATE_FORMAT(P.HORA_EMBARQUE,'%Hh%i') AS HORA_EMBARQUE,
									P.ORIGEM,
									P.DESTINO,
									DATE_FORMAT(S.DATA_CAD,'%d/%m/%Y') as DATA_CAD,
									U.ORG_ID,
									O.ORG_RAZAO,
									U.USU_NOME,
									U.USU_EMAIL,
									U.USU_TELEFONE,
									U.PERF_ID,
									CASE S.TIPO_SERVICO  
									 WHEN 'C' THEN 'CONVECIONAL' 
									 WHEN 'E' THEN 'EXECUTIVO' 
									 WHEN 'L' THEN 'LEITO'
									END AS TIPO_SERVICO,
				                    E.EMP_FANTASIA,	
									S.STATUS,				
									S.OBS,
									(SELECT COUNT(PASSAGENS.SOL_ID) FROM PASSAGENS WHERE PASSAGENS.SOL_ID = S.SOL_ID) AS QTDE_PASSAGEM						  
								  FROM
									SOLICITACOES S	
									INNER JOIN PASSAGENS P ON (S.SOL_ID = P.SOL_ID)					  
									INNER JOIN ORGAOS    O ON (S.ORG_ID = O.ORG_ID)
									INNER JOIN USUARIOS  U ON (S.USU_ID = U.USU_ID)
				                    INNER JOIN EMPRESAS  E ON (S.EMP_ID = E.EMP_ID)
								WHERE S.SOL_ID  IN( ".$id.")
								ORDER BY S.SOL_ID ";


				if ($query=mysqli_query($con,$qry)){

				 	while ($master=mysqli_fetch_assoc($query)){ 
				 		$STATUS_SOLIC  = $master['STATUS'];
				 	  	$USUARIO_SOLIC = $master['USU_NOME'];
				 	  	$USUARIO_EMAIL = $master['USU_EMAIL'];
				 	  	$ORIGEM        = $master['ORIGEM'];
				 	  	$DESTINO       = $master['DESTINO'];
				 	  	$DATA_EMBARQUE = $master['DATA_EMBARQUE'];
				 	  	$HORA_EMBARQUE = $master['HORA_EMBARQUE'];
				 	  	$EMP_FANTASIA  = $master['EMP_FANTASIA'];
				 	  	$TIPO_SERVICO  = $master['TIPO_SERVICO'];
				 	  	$ID_SOLICITACAO = $master['SOL_ID'];

				 	  	
				 	}
				}

			
				 	  	

			?>					
			<div class="row-fluid text-left">
				<div class="table-responsive " style="display:inline;"> 
					<table class="display table table-hover table-striped" >
						<thead>
                            <div class="row-fluid">
                            	<div class="row" >

                            		<tr >  
										<th width="30%">Origem</th>  
										<th width="30%">Destino</th>  
										<th width="15%">Dt de Embarque</th>  
										<th width="5%">Horário</th> 
										<th width="15%">Tipo de Serviço</th> 						
										<th width="30%">Empresa</th> 
										
									</tr> 
									<tr style="color: #000; background-color: #fff; " >  
										<th width='30%' > <?php echo utf8_encode($ORIGEM) ?>  </th>  
										<th width='15%'> <?php echo utf8_encode($DESTINO) ?> </th>  
										<th width='10%'> <?php echo $DATA_EMBARQUE ?>  </th>  
										<th width='5%'> <?php echo $HORA_EMBARQUE ?>  </th> 
										<th width='15%'> <?php echo $TIPO_SERVICO ?>  </th> 	
										<th width='30%' > <?php echo $EMP_FANTASIA ?>  </th> 	
										
													
									</tr>
                            	</div>

								<div class="pull-left">
									<strong><i class="fa fa-map-marker" aria-hidden="true"></i> De: <?php echo utf8_encode($ORIGEM).' para '.utf8_encode($DESTINO); ?></strong>	
								</div> 	
								<div class="pull-right">
									<p><strong>Dia <?php echo $DATA_EMBARQUE.' às '.$HORA_EMBARQUE; ?></strong>	</p>		
								</div> 
							</div>	
						  
						  <tr style="color: #FFF; background-color:#286090;">  
							<th width="40%" colspan="3">Nome do Passageiro</th>  
							<th width="15%">CPF</th>  
							<th width="10%">RG</th>  
							<th width="20%">Cartão</th> 
							 
						  </tr>  
						
						</thead>  
						<tbody> 
			<?php
			$qrypassagem = "SELECT							 
							 concat('status_', lcase(upper_retira_acento(st.STATUS))) AS STATUS_COR,
							  ST.STATUS,
							  CASE S.TIPO_SERVICO  
							   WHEN 'C' THEN 'CONVECIONAL' 
							   WHEN 'E' THEN 'EXECUTIVO' 
							   WHEN 'L' THEN 'LEITO'
							  END AS TIPO_SERVICO,
							  P.ID AS PAS_ID,
							  P.PASSAGEIRO,
							  P.CPF,
							  P.RG,
							  P.CARTAO_FIDELIDADE,
							  P.ORIGEM,
							  P.DESTINO,
							  DATE_FORMAT(P.DATA_EMBARQUE,'%d/%m/%Y' ) as DATA_EMBARQUE,
							  DATE_FORMAT(P.HORA_EMBARQUE,'%Hh%i') AS HORA_EMBARQUE,
							  P.BILHETE,
							  (SELECT EMP_FANTASIA FROM EMPRESAS WHERE EMP_ID = S.EMP_ID LIMIT 1 ) AS EMP_FANTASIA,
							  P.VR_UNITARIO,
							  P.TAXA_EMBARQUE,
							  P.TAXA_ADMIN,
							  P.VR_TOTAL,
							  P.DATA_CAD  
							FROM
							  SOLICITACOES S							  
							  INNER JOIN PASSAGENS P ON (S.SOL_ID = P.SOL_ID)
                              INNER JOIN STATUS ST ON (S.STATUS = ST.STATUS_ID)	
							WHERE S.SOL_ID =".$ID_SOLICITACAO." 
							ORDER BY S.SOL_ID ";
               
			    
				if ($resul_passagem=mysqli_query($con,$qrypassagem)){
					$QTDE_PASSAGEM = mysqli_num_rows($resul_passagem);
				     while ($linha=mysqli_fetch_assoc($resul_passagem)){ 

				 	$DATA_EMBARQUE = $linha['DATA_EMBARQUE'];
				 	$HORA_EMBARQUE = $linha['HORA_EMBARQUE'];

				 	
			?>					
						  <tr>  
							<th width="40%" colspan="3"><?php echo utf8_encode($linha['PASSAGEIRO']);  ?></th>  
							<th width="15%"><?php echo mask($linha['CPF'],'###.###.###-##');  ?></th>  
							<th width="10%"><?php echo $linha['RG'];  ?></th>  
							<th width="20%"><?php echo $linha['CARTAO_FIDELIDADE'];  ?>
							
							</th> 
						  
							
						  </tr> 
						  


						  <?php	 
					}
	            }  
	            } 	

	      	
	      ?>   </tbody>
						
					</table> 
				</div> 
				<div class="row">
				<p class="text-left">&nbsp;&nbsp;&nbsp;&nbsp;Qtde de Passagens: <?php echo $QTDE_PASSAGEM; ?></p>
				</div>
	
						
					
				

				
			</div> 
			 
            <div class="row-fluid">
			<p class="text-left"><strong>Qtde Total de Passagens: <?php echo $QTDE_TOTAL_PASSAGEM; ?></strong></p>
			</div>		


			<p>&nbsp;</p>

			<?php

			  if(!empty($OBS))
			  	 echo '	<div class="panel panel-default">
						  <div class="panel-heading"><strong>Observações</strong></div>
						  <div class="panel-body">
						      '.$OBS.'
						  </div>
						</div>';
			
			?>
		
			<p>&nbsp;</p>
			
			<div class="row-fluid text-left">	
				<p>Atenciosamente,</p>
				
				<span><strong><?php echo utf8_encode($GESTOR_NOME); ?></strong></span><br>
				<span>Gestor do Contrato</span>
				<p>Telefone: </p>
				<span><?php echo utf8_encode($GESTOR_TELEFONE); ?></span>
			</div>
			
			
			
		 
			
		

		  
		  </div>
		  <?php
		 		#verifica se a solicitação esta com o status 3 autorização e se o usuario é um gestor 

		 		// }
		 	?>
		 </div>
		 
	 

	<!-- these js files are used for making PDF -->
	
	  
	  </div>
	 <!-- </div>  -->

	<!-- </div> -->


<script type="text/javascript">
	         function printPage() {    
		                window.print();
	          }
       </script>




	


<?php
			mysqli_free_result($resultado);
			if(!empty($resul_passagem)){
			mysqli_free_result($resul_passagem);
		}
			mysqli_close($con);
			
		?>




<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js"></script>

</body>


</html>

 

pag 1.gif

pag 2.gif

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...