<?php
    //Incluindo a conexão com banco de dados   
    include("cabecalho.php");
	include("config/conexao.php"); 
	

	$id = $_GET['id'];
	$sql  = "SELECT * FROM glpi_tickets WHERE id = '{$id}' "; //INNER JOIN glpi_useremails um on u.id = um.users_id 
	$res = mysqli_query($conn, $sql);	
	$row_rec = mysqli_fetch_array($res);

	$sql1  = "SELECT * FROM glpi_itilfollowups WHERE items_id = '{$id}' ";
	$res1 = mysqli_query($conn, $sql1);
	$row  = mysqli_num_rows($res1);
 
 	$sql2  = "SELECT * FROM glpi_documents WHERE tickets_id = '{$id}' ";
	$res2 = mysqli_query($conn, $sql2);
	$row2  = mysqli_num_rows($res2);
 
  	$sql3  = "SELECT * FROM glpi_itilsolutions WHERE items_id = '{$id}' ";
	$res3 = mysqli_query($conn, $sql3);
	$row3  = mysqli_num_rows($res3);
 
	$atend = 'hidden';
	$arquivo = 'hidden';
	$fechamento = 'hidden';	
?>

<!DOCTYPE html>
<!--<html lang="pt-br">

<head>
  <meta charset="utf-8">
  <title>Central de Atendimento</title>
  <meta name="author" content="">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="css/plugins/pace/pace.css" rel="stylesheet">
  <script src="js/pace/pace.js"></script>
  <link href="css/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href='css/fonts/google/fonte.css' rel="stylesheet" type="text/css">
  <link href="css/fonts/font-awesome/css/font-awesome.min.css" rel="stylesheet">
  <link href="css/plugins/datatables/datatables.css" rel="stylesheet">
  <link href="css/style.css" rel="stylesheet">
  		<style type="text/css">
			.carregando{
				color:#ff0000;
				display:none;
			}
		</style>
</head>

<body>
  <div id="wrapper"> -->
    <!-- INICIO MENU DE NAVEGAÇÃO -->
<!--			<nav class="navbar-top" role="navigation">
				<div class="navbar-header">
					<button type="button" class="navbar-toggle pull-right" data-toggle="collapse" data-target=".sidebar-collapse">
						<i class="fa fa-bars"></i> Menu
					</button>
					<div class="navbar-brand">					
						<a href="index">
							<img src="img/adapter_bco.svg"   style="width: 70%;">
						</a>
					</div>
				</div>
				<div class="nav-top">
					<ul class="nav navbar-right">
						<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">		
								<i class="fa fa-user"></i>&nbsp&nbsp<?php echo $_SESSION['usuarioNome']; ?>&nbsp&nbsp<i class="fa fa-caret-down"></i>
							</a>		
							<ul class="dropdown-menu dropdown-user">
								<li>
									<a href="">
										<i class="fa fa-user"></i> Dados Pessoais
									</a>
								</li>
								<li>
									<a href="#" data-toggle="modal" data-target="#AlterarSenha">
										<i class="fa fa-gear"></i> Configurações
									</a>
								</li>
								<li class="divider"></li>
								<li>
									<a class="logout_open" href="logoff.php">
										<i class="fa fa-sign-out"></i> Sair
									</a>
								</li>
							</ul>
						</li>
					</ul>
				</div>
			</nav> -->
    <!-- FIM MENU DE NAVEGAÇÃO -->
    <div id="page-wrapper">
      <div class="page-content">
        <div class="row">
          <div class="col-lg-12">
            <div class="page-title">
              <ol class="breadcrumb">
                <li>
                  <i class="fa fa-home"></i> <a href="home.php">Home</a>
                </li>
				<li>
				  <i class="fa fa-comments"></i> <a href="atendimentos.php">Atendimentos</a>	
				</li>
                <li class="active"><i class="fa fa-tasks"></i> Acompanhar</li>
              </ol>
            </div>
          </div>
        </div>
		<?php $teste = 'hidden'; ?>
				<div>
					<div class="row">
						<div class="col-lg-4">
							<a href="#" class="btn btn-primary btn-lg btn-block" role="button" aria-pressed="true" data-toggle="modal" data-target="#NovoAcompanhamento" data-placement="top" title="Novo"> 
								<i class="fa fa-comments"></i>Acompanhamento 
								<?php 
									$target = "NovoAcompanhamento";
									$titulo = "Novo Acompanhamento";
									$caminho = "acao=cadacomp";
								?>
							</a>
						</div>				
						<div class="col-lg-4">
							<a href="#" class="btn btn-info btn-lg btn-block" role="button" aria-pressed="true" data-toggle="modal" data-target="#NovoArquivo" data-placement="top" title="Novo">  
								Enviar Arquivo   
							</a>
						</div>						
<!--						<div class="col-lg-3">
							<a href="#" class="btn btn-warning btn-lg btn-block" role="button" aria-pressed="true">      Tarefa    </a>
						</div>
-->						<div class="col-lg-4">
							<a href="#" class="btn btn-success btn-lg btn-block" role="button" aria-pressed="true" data-toggle="modal" data-target="#NovaFechamento" data-placement="top" title="Fechar">
								Fechar Chamado							
							</a>
						</div>
					</div>
				</div>	
<br>

		<!-- Fechamento --->
		<?php if ($row3 > 0){ 
				$fechamento = '';
				while($row3 = mysqli_fetch_assoc($res3)){ ?>
				<div class="portlet portlet-default" <?php echo $fechamento;?>>		  
					  <div class="portlet-body">		
						<div id="basicFormExample" class="panel-collapse collapse in">
						  <div class="portlet-body">
							<!------------------------>
							<div class= "row">
								<div class="col-lg-12">
									<div class="form-group">
									  <label><b>Descrição:</b></label>
									  <textarea class="form-control" rows="10" placeholder="Descreva detalhadamente o problema." name="descricao" id="descricao" readonly><?php echo $row3['content']; ?></textarea>
									</div>
								</div>					
							</div>
						   <!------------------------>
						  </div>
						</div>		
					  </div>   
				</div>
				<?php 
			}
		} 
		?>					
		<!-- Solução --->
		<?php if ($row3 > 0){ 
				$arquivo = '';
				while($row3 = mysqli_fetch_assoc($res3)){ ?>
				<div class="portlet portlet-default" <?php echo $solucao;?>>		  
					  <div class="portlet-body">		
						<div id="basicFormExample" class="panel-collapse collapse in">
						  <div class="portlet-body">
							<!------------------------>
							<div class= "row">
								<div class="col-lg-12">
									<div class="form-group">
									  <label><b>Descrição:</b></label>
									  <textarea class="form-control" rows="10" placeholder="Descreva detalhadamente o problema." name="descricao" id="descricao" readonly><?php echo $row2['content']; ?></textarea>
									</div>
								</div>					
							</div>
						   <!------------------------>
						  </div>
						</div>		
					  </div>   
				</div>
				<?php 
			}
		} 
		?>					
		<!-- Arquivo --->
		<?php if ($row2 > 0){ 
				$arquivo = '';
				while($row2 = mysqli_fetch_assoc($res2)){ ?>		

				<div class="portlet portlet-default" <?php echo $arquivo;?>>		  
					  <div class="portlet-body">		
						<div id="basicFormExample" class="panel-collapse collapse in">
						  <div class="portlet-body">
							<!------------------------>
							<div class= "row">
								<div class="col-lg-12">
									<div class="form-group">
									  <label><b>Descrição:</b></label>
									  <textarea class="form-control" rows="10" placeholder="Descreva detalhadamente o problema." name="descricao" id="descricao" readonly><?php echo $row2['content']; ?></textarea>
									</div>
								</div>					
							</div>
						   <!------------------------>
						  </div>
						</div>		
					  </div>   
				</div>
				<?php 
			}
		} 
		?>				
		<!-- Atendimento --->
		<?php if ($row > 0){ 
				$atend = '';
				while($row = mysqli_fetch_assoc($res1)){ ?>

				<div class="portlet portlet-default" <?php echo $atend;?>>		  
					  <div class="portlet-body">		
						<div id="basicFormExample" class="panel-collapse collapse in">
						  <div class="portlet-body">
							<!------------------------>
							<div class= "row">
								<div class="col-lg-12">
									<div class="form-group">
									  <label><b>Descrição:</b></label>
									  <textarea class="form-control" rows="10" placeholder="Descreva detalhadamente o problema." name="descricao" id="descricao" readonly><?php echo $row['content']; ?></textarea>
									</div>
								</div>					
							</div>
						   <!------------------------>
						  </div>
						</div>		
					  </div>   
				</div>		
				<?php 
			}
		} 
		?>
		<!-- Chamado --->
		<div class="box">
        <div class="portlet portlet-default box">		  
			  <div class="portlet-body">		
				<div id="basicFormExample" class="panel-collapse collapse in">
				  <div class="portlet-body">
					<!------------------------>
		
					<div class= "row">
						<div class="col-lg-12">
							<div class="form-group">
							  <label><b>Título:</b></label>
							  <input type="text" class="form-control" placeholder="" name="titulo" id="titulo" value=<?php echo $row_rec['name']; ?> readonly/>
							</div>
						</div>
						<div class="col-lg-12">
							<div class="form-group">
							  <label><b>Descrição:</b></label>
							  <textarea class="form-control" rows="10" placeholder="Descreva detalhadamente o problema." name="descricao" id="descricao" readonly><?php echo $row_rec['content']; ?></textarea>
							</div>
						</div>					
					</div>
				   <!------------------------>
				  </div>
				</div>		
			  </div>   
        </div>
		</div>
      </div>
    </div>
  </div>

  <!-- -------------------------------------------------------------------------------------------------------------------------->
    <div class="modal modal-flex fade" id="NovoAcompanhamento" tabindex="-1" role="dialog" aria-labelledby="flexModalLabel" aria-hidden="true">
      <div class="modal-dialog">
		 <form  action="config/script_chamado.php?acao=cadacomp" method="POST" enctype="multipart/form-data">
			<div class="modal-content">
			  <div class="modal-header">
				<button type="button" id="CloseModal" name="CloseModal" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="flexModalLabel" style="color:white;">
				  <i class="fa fa-comments"></i> Novo Acompanhamento
				</h4>
			  </div>
			 <div class="modal-body">
				<div id="basicFormExample" class="panel-collapse collapse in">
				  <div class="portlet-body">
					<!------------------------>
	
					<div class= "row">		
						<div class= "row">
							<div class="col-lg-12">
								<div class="form-group">
								  <label><b>Descrição:</b></label>
								  <input type="hidden" name="ID_USUARIO" id="ID_USUARIO" value="<?php echo $_SESSION['usuarioId']; ?>"/>
								  <input type="hidden" name="id_ticket" id="id_ticket" value="<?php echo $id; ?>"/>
								  <textarea class="form-control" rows="10" placeholder="Descreva detalhadamente o problema." name="descricao" id="descricao"></textarea>
								</div>
							</div>					
						</div>
					</div>	
				   <!------------------------>
				  </div>
			    </div>
			  </div>	
			  <div class="modal-footer">
				<button type="button" id="Cancelar" name="Cancelar" class="btn btn-default" data-dismiss="modal">Cancelar</button>
				<button type="submit" id="Salvar" name="Salvar" onclick="return ValidarCadastro();" class="btn btn-green">
				  <i class="fa fa-save"></i> Salvar
				</button>
			  </div>
			</div>
		</form>	
      </div>
    </div>
  <!-- -------------------------------------------------------------------------------------------------------------------------->
 
    <div class="modal modal-flex fade" id="NovaFechamento" tabindex="-1" role="dialog" aria-labelledby="flexModalLabel" aria-hidden="true">
      <div class="modal-dialog">
		 <form  action="config/script_chamado.php?acao=cadafech" method="POST" enctype="multipart/form-data">
			<div class="modal-content">
			  <div class="modal-header">
				<button type="button" id="CloseModal" name="CloseModal" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="flexModalLabel" style="color:white;">
				  <i class="fa fa-comments"></i> Fechamento
				</h4>
			  </div>
			 <div class="modal-body">
				<div id="basicFormExample" class="panel-collapse collapse in">
				  <div class="portlet-body">
					<!------------------------>
	
					<div class= "row">		
						<div class= "row">
							<div class="col-lg-12">
								<div class="form-group">
								  <label><b>Descrição:</b></label>
								  <input type="hidden" name="ID_USUARIO" id="ID_USUARIO" value="<?php echo $_SESSION['usuarioId']; ?>"/>
								  <input type="hidden" name="id_ticket" id="id_ticket" value="<?php echo $id; ?>"/>
								  <textarea class="form-control" rows="10" placeholder="Descreva detalhadamente o problema." name="descricao" id="descricao"></textarea>
								</div>
							</div>					
						</div>
					</div>	
				   <!------------------------>
				  </div>
			    </div>
			  </div>	
			  <div class="modal-footer">
				<button type="button" id="Cancelar" name="Cancelar" class="btn btn-default" data-dismiss="modal">Cancelar</button>
				<button type="submit" id="Salvar" name="Salvar" onclick="return ValidarCadastro();" class="btn btn-green">
				  <i class="fa fa-save"></i> Salvar
				</button>
			  </div>
			</div>
		</form>	
      </div>
    </div>
  <!-- --------------------------------------------------------------------------------------------------------------------------> 
  
  
  <script type="text/javascript" src="https://www.google.com/jsapi"></script>		
  <script src="js/jquery/jquery-1.8.1.js"></script>
  <script src="js/jquery/jquery.maskedinput.js"></script>
  <!--<script src="js/jquery/jquery.cadastro.usuario.js"></script>-->
  <script src="js/bootstrap/bootstrap.min.js"></script>
  <script src="js/slimscroll/jquery.slimscroll.min.js"></script>
  <script src="js/popupoverlay/jquery.popupoverlay.js"></script>
  <script src="js/popupoverlay/defaults.js"></script>
  <script src="js/popupoverlay/logout.js"></script>
  <script src="js/hisrc/hisrc.js"></script>
  <script src="js/datatables/jquery.dataTables.js"></script>
  <script src="js/datatables/datatables-bs3.js"></script>
  <script src="js/jquery/jquery.Layout.js"></script>

		<script type="text/javascript">
		$(function(){
			$('#TIPO').change(function(){
				if( $(this).val() ) {
					$('#CATEGORIA').hide();
					$('.carregando').show();
					$.getJSON('config/categorias.php?search=',{TIPO: $(this).val(), ajax: 'true'}, function(j){
						var options = '<option value="">Escolha Subcategoria</option>';	
						console.log(options);
						for (var i = 0; i < j.length; i++) {
							options += '<option value="' + j[i].id + '">' + j[i].completename + '</option>';
						}	
						$('#CATEGORIA').html(options).show();
						$('.carregando').hide();
					});
				} else {
					$('#CATEGORIA').html('<option value="">– Escolha Subcategoria –</option>');
				}
			});
		});
		</script>
	
</body>

</html>
