<?php
session_start();
if (!isset($_SESSION['idUsuarioLogado'])) {
  header("location: ./");
}
require("../database/dbConection.php");

if($_GET['viewheader']=="true"){
  $liAgendamentoAvulso  = "";
  include_once("header.php");
}else{
  $liAgendamentoAvulso  = "";
  include_once("header-clean.php");  
}
/************************************************************************************/
if(isset($_GET['tpag']) && $_GET['tpag']=="lab"){
  $paginaTermina = "agendamento_impressao_termica_lab.php";
  $paginaA4      = "agendamento_impressao_A4_lab.php";
  $paginaBuscaPaciente = "paciente_buscar?op=ald";
}else{
  $paginaTermina = "agendamento_impressao_termica.php";
  $paginaA4      = "agendamento_impressao_A4.php";
  $paginaBuscaPaciente = "paciente_buscar?op=aa";
}

if(isset($_GET['oci']) && $_GET['oci']=="S"){
  $impressaoOCI = "s";
}else{
  $impressaoOCI = "n";
}
?>
<div class="app-content content" style="background-color: #e1e9e7;" id='content_resultado'>
  <div class="content-wrapper" style="padding: 10px;">
    <section id="ordering">
      <div class="row">
        <div class="col-12">
          <div class="card" style="border: gray 1px solid;" id="card-tela">
						<div class="card-header titulo-telas">
							<i class="icofont icofont-print" style='margin-top:-15px !important'></i>&nbsp;Impressão de Agendamento
							<a class="heading-elements-toggle"><i class="fa fa-ellipsis-v font-medium-3"></i></a>
							<div class="heading-elements">
								<ul class="list-inline mb-0" style="margin-top: -12px; color: #fff;">
									<li>
										<a data-action="collapse"><i class="ft-minus"></i></a>
									</li>
									<li>
										<a data-action="expand"><i class="ft-maximize"></i></a>
									</li>
								</ul>
							</div>
						</div>
            <div class="card-content collapse show">
              <div class="card-body novo-padding-cardbody">
                <div class="row">
                  <div class="col-md-12">
                    <div class="form-group">
                      <ul class="nav nav-tabs nav-topline">
                        <li class="nav-item">
                          <a class="nav-link active" id="base-impressaoTermina" data-toggle="tab" aria-controls="impressaoTermina" href="#impressaoTermina" aria-expanded="true"><b><i class='icofont icofont-paper'></i> IMPRESSORA TÉRMICA&nbsp;&nbsp;</b></a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" id="base-impressaoA4" data-toggle="tab" aria-controls="impressaoA4" href="#impressaoA4" aria-expanded="true"><b><i class='fa fa-file-text-o'></i> IMPRESSÃO EM TAMANHO A4&nbsp;&nbsp;</b></a>
                        </li>
                      </ul>
                      <div class="tab-content px-1 pt-1 border-grey border-lighten-2 border-0-top">
                        <div role="tabpanel" class="tab-pane active" id="impressaoTermina" aria-expanded="true" aria-labelledby="base-impressaoTermina">
                          <form class="form">
                            <div class="form-body">
                              <div class="row">
                                <div class="col-md-12">
                                  <div class="form-group">
                                    <iframe style='width:100%' frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="<?php echo $paginaTermina;?>" target="_top" id='iframeTermica'>
                                    </iframe>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </form>
                        </div>
                        <div class="tab-pane" id="impressaoA4" aria-labelledby="base-impressaoA4">
                        <form class="form">
                            <div class="form-body">
                              <div class="row">
                                <div class="col-md-12">
                                  <div class="form-group">
                                  <iframe style='width:100%' frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="<?php echo $paginaA4;?>"  target="_top" id='iframeA4'>
                                    </iframe>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </form>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
</div>

<div class="barra-flutuante">
  <?php
  if($_GET['viewheader']=="falseview"){
    echo "<button type='button' class='btn btn-danger' id='btnCancelar' onClick='window.close()'>
    <i class='ft-log-out botaoOk'></i> Fechar
  </button>";
  }else if($_GET['viewheader']=="notfalseview"){
    echo "<button type='button' class='btn btn-danger' id='btnCancelar' onClick='window.close()'>
    <i class='ft-log-out botaoOk'></i> Fechar
  </button>";
  }else if($_GET['viewheader']=="backview" && !isset($_GET['oci'])){
    echo "<button type='button' class='btn btn-warning' id='btnVoltar' onClick='voltarAgendamentoDireto()' style='width:130px'>
    <i class='ft-log-out botaoOk'></i> Voltar
  </button>";
  }else if($_GET['viewheader']=="backview" && isset($_GET['oci'])){
    echo "<button type='button' class='btn btn-danger' id='btnCancelar' onClick='window.close()'>
    <i class='ft-log-out botaoOk'></i> Fechar
  </button>";
  }else{
    $onclickLocation = '"window.location.href='."'paciente_buscar?op=aa'".'"';
    echo "<button type='button' class='btn btn-blue' onClick=$onclickLocation>
    <i class='icofont icofont icofont-medical'></i>&nbsp;&nbsp;Novo Agendamento
    </button>";
  }
  ?>  
</div>

<?php
  include_once("footer.php");
?>

<script src="../app-assets/vendors/js/forms/extended/inputmask/jquery.inputmask.bundle.min.js"></script>
<script src="../app-assets/js/scripts/forms/extended/form-inputmask.min.js"></script>
<script src="../app-assets/vendors/js/tables/datatable/datatables.min.js"></script>
<script src="../app-assets/js/scripts/tables/datatables/datatable-basic.min.js"></script>
<script src="../app-assets/js/scripts/ui/jquery-ui/buttons-selects.min.js"></script>

<script>
  var liAgendamentoAvulso = "<?php echo $liAgendamentoAvulso;?>";
  if(liAgendamentoAvulso!=""){
    $("#liAgendamentoAvulso").attr('class', 'active');
	  $("#liAgendamentoAvulso").css("border-bottom", "2px solid #c4c8ca");    
  }
  var alturaContainer = document.getElementById('content_resultado').clientHeight;
  $("#impressaoTermina").css("height",alturaContainer-180);
  $("#iframeTermica").css("height",alturaContainer-200);
  $("#iframeA4").css("height",alturaContainer-200);


  function voltarAgendamentoDireto(){

    window.location.href="<?php echo $paginaBuscaPaciente;?>";
  }
</script>