<?php
    include_once 'bd/conexion.php';
    $objeto = new Conexion();
    $conexion = $objeto->Conectar();
    
    $idC = trim($_GET['idC']);
    
    $consulta = "SELECT p.documento,p.nombre,p.telefono,p.correo,p.sexo,e.especialidad,h.hospital,DATE_FORMAT(c.fecha_cita,'%h:%i %p %e/%m/%Y') AS 'fecha',DATE_FORMAT(c.fecha_estimacion_cita,'%h:%i %p %e/%m/%Y') AS 'fecha_estimacion',e.id_especialidad FROM CITAS AS c INNER JOIN PACIENTES AS p ON (c.id_paciente = p.documento) INNER JOIN ESPECIALIDADES AS e ON (c.id_especialidad = e.id_especialidad) INNER JOIN HOSPITALES AS h ON (c.id_hospital = h.id_hospital) WHERE c.id_cita = ".$idC.";";
    $resultado = $conexion->prepare($consulta);
    $resultado->execute();
    $data=$resultado->fetch(PDO::FETCH_ASSOC);
    
    $consultaP = "SELECT * FROM PROCEDIMIENTOS;";
    $resultadoP = $conexion->prepare($consultaP);
    $resultadoP->execute();
    $dataP=$resultadoP->fetchAll(PDO::FETCH_ASSOC);

?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title></title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 4 -->
  <link rel="stylesheet" href="public/bootstrap 4/dist/css/bootstrap.min.css">
  <!-- DataTable -->
  <link rel="stylesheet" href="plugins/data/dataTables.bootstrap4.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
  <!-- Ionicons -->
  <!-- <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> -->  
  <!-- Theme style -->
  <link rel="stylesheet" href="public/dist/css/AdminLTE_Forma.min.css">
  <!-- select2 -->
  <link rel="stylesheet" href="plugins/select2/select2.min.css">
  <!-- DataTimePicker -->
  <link rel="stylesheet" href="plugins/datetimepicker/tempusdominus-bootstrap-4.min.css">
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="plugins/iCheck/all.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">
	<div class="wrapper">
		<div class="content-wrapper">
			<section class="content-header">
				<h1>Asignación<small>Citas</small></h1>
			</section>
			<section class="content">
				<div id="alerta"></div>				
                <div class="row">
					<div class="col-md-6">
						<div class="box box-primary">
							<div class="box-header">
								<h3 class="box-title">Datos del paciente</h3>
							</div>
							<div class="box-body">
							    <div class="form-group">
									<div class="row">
									    <div class="col-md-6">
											<label>Fecha Solicitud Cita:</label>
											<input name="login" type="text" class="form-control" id="login" value="<?php echo $data['fecha']; ?>" required disabled>
										</div>
										<div class="col-md-6">
											<label>Fecha Estimación Cita:</label>
											<input name="login" type="text" class="form-control" id="login" value="<?php echo $data['fecha_estimacion']; ?>" required disabled>
										</div>
									</div>
                                </div>
							    <div class="form-group">
									<div class="row">
									    <div class="col-md-5">
											<label>Documento:</label>
											<input name="login" type="text" class="form-control" id="login" value="<?php echo $data['documento']; ?>" required disabled>
										</div>
										<div class="col-md-7">
											<label>Nombre:</label>
											<input name="login" type="text" class="form-control" id="login" value="<?php echo $data['nombre']; ?>" required disabled>
										</div>
									</div>
                                </div>
								<div class="form-group">
									<div class="row">
										<div class="col-md-2">
											<label>Sexo:</label>
											<input name="contra" type="text" class="form-control" id="contra" value="<?php echo $data['sexo']; ?>" required disabled>
										</div>
										<div class="col-md-4">
											<label>Telefono:</label>
											<input name="contra" type="number" class="form-control" id="contra" value="<?php echo $data['telefono']; ?>" required disabled>
										</div>
                                        <div class="col-md-6">
											<label>Correo:</label>
											<input name="correo" type="email" class="form-control" id="correo" value="<?php echo $data['correo']; ?>" required disabled>
										</div>										
									</div>
                                </div>
                                <div class="form-group">
									<div class="row">
									    <div class="col-md-4">
											<label>Especialidad:</label>
											<input name="contra" type="text" class="form-control" id="contra" value="<?php echo $data['especialidad']; ?>" required disabled>
										</div>
                                        <div class="col-md-8">
											<label>Hospital Solicitado:</label>
											<input name="id_usua_sahi" type="text" class="form-control" id="id_usua_sahi" value="<?php echo $data['hospital']; ?>" required disabled>
										</div>
									</div>
                                </div>                                                               
							</div>
						</div>
                    </div>
                    <div class="col-md-6">
						<div class="box box-primary">
							<div class="box-header">
								<h3 class="box-title">Procedimiento</h3>
							</div>
                            <input name="accion" id="accion" type="hidden" value="Agregar">   
                            <input name="idsProduc" id="idsProduc" type="hidden">
                            <input name="idC" id="idC" type="hidden" value="<?php echo $idC; ?>">
                            <input name="idE" id="idE" type="hidden" value="<?php echo $data['id_especialidad']; ?>">
							<div class="box-body">								
                                <div class="form-group">
									<div class="row">
										<div class="col-md-5">
											<label>Elija el Hospital:</label>
											<select id="hospital" class="form-control" style="width: 100%;" tabindex="-1" aria-hidden="true">
                                                <option value="1">HOSPITAL REGIONAL ALFONSO JARMAILLO SALAZAR ESE</option>
                                                <option value="2">HOSPITAL SAN JUAN DE DIOS DE HONDA</option>
                                                <option value="3">ESPINAL</option>
                                                <option value="4">CHAPARRAL</option>
                                                <option value="5">LA DORADA</option>
                                                <option value="6">LERIDA</option>
                                            </select>
										</div>										
									</div>
                                </div>                                
                                <div class="form-group">
									<div class="row">
										<div class="col-md-3">
											<label>N° de Autorización:</label>
											<input name="nAuth" type="text" class="form-control" id="nAuth">
										</div>
										<div class="col-md-5">
											<label>Fecha Autorización:</label>
											<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
                                                <input id="fechaAuth" type="text" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
                                                <div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
                                                    <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                                                </div>
                                            </div>
										</div>
                                        <div class="col-md-3">
											<label>Días de Vigencia:</label>
											<input name="dVig" type="text" class="form-control" id="dVig">
										</div>										
									</div>
                                </div>
                                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
                                    Procedimientos
                                </button>
                                <br>
                                <div class="form-group">
                                    <div id="DivProductos" style="width:100%; height:350px; overflow-y: scroll;">
                                    </div>
                                </div>
								<button class="btn btn-success btn-sm " id="BtnAsignar">
									<span class="glyphicon glyphicon-check"></span> Asignar
								</button>
								<!-- Modal -->
                                <div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
                                    <div class="modal-dialog modal-dialog-centered" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <h5 class="modal-title" id="exampleModalLongTitle">Procedimientos</h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <table id="example1" class="table table-borderless display responsive" style="width:100%">
                                                    <thead>
                                                        <tr>                                                        
                                                            <th>Cod. Cups</th>
                                                            <th>Procedimiento</th>
                                                            <th>Genero</th>
                                                            <th></th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php
                                                            foreach ($dataP as $res) {                                            
                                                        ?>
                                                            <tr>
                                                                <td width="10%"><?php echo $res['cod_cups']; ?></td>
                                                                <td width="70%"><?php echo $res['procedimiento']; ?></td>
                                                                <td width="10%"><?php echo $res['genero']; ?></td>
                                                                <td width="10%"><input id='<?php echo $res['id_procedimiento']; ?>' name='check[]' type='checkbox' class='minimal' id='checklist' value='<?php echo $res['id_procedimiento']; ?>'></td>
                                                            </tr>
                                                        <?php
                                                            }
                                                        ?>
                                                    </tbody>
                                                    <tfoot>
                                                        <tr>
                                                            <th>Cod. Cups</th>
                                                            <th>Procedimiento</th>
                                                            <th>Genero</th>
                                                            <th></th>
                                                        </tr>                                                      
                                                    </tfoot>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
							</div>
						</div>
					</div>
				</div>
			</section>
        </div>	
		<!-- /.content-wrapper -->
		<footer class="main-footer">
			<div class="pull-right hidden-xs">
				<b>Version</b> 2.3.2
			</div>
			<strong>Copyright &copy; 2014-2015 <a href="http://almsaeedstudio.com">Almsaeed Studio</a>.</strong> All rights reserved.
		</footer>
		
		<!-- /.control-sidebar -->
		<!-- Add the sidebar's background. This div must be placed immediately after the control sidebar -->
		<div class="control-sidebar-bg"></div>
	</div>
<!-- ./wrapper -->

<!-- jQuery 2.2.0 -->
<script src="plugins/datatable/jQuery-3.3.1/jquery-3.3.1.js"></script>
<!-- Bootstrap 4 -->
<script src="public/bootstrap 4/dist/js/popper.min.js"></script>
<script src="public/bootstrap 4/dist/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/data/jquery.dataTables.min.js"></script>
<script src="plugins/data/dataTables.bootstrap4.min.js"></script>
<!-- Select2 -->
<script src="plugins/select2/select2.full.min.js"></script>
<!-- DateTimePicker -->
<script src="plugins/datetimepicker/moment.min.js"></script>
<script src="plugins/datetimepicker/tempusdominus-bootstrap-4.min.js"></script>
<script src="plugins/datetimepicker/es.js"></script>
<!-- Ajax -->
<script src="funciones.ajax.js"></script>
<!-- iCheck -->
<script src="plugins/iCheck/icheck.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>

<script>
    $(function () {
        //Initialize Select2 Elements
        $(".select2").select2();
  
        $("#example1").DataTable({
            "scrollX" : true,
            "language": {
                "sProcessing":    "Procesando...",
                "sLengthMenu":    "Mostrar _MENU_ registros",
                "sZeroRecords":   "No se encontraron resultados",
                "sEmptyTable":    "Ningún dato disponible en esta tabla",
                "sInfo":          "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
                "sInfoEmpty":     "Mostrando registros del 0 al 0 de un total de 0 registros",
                "sInfoFiltered":  "(filtrado de un total de _MAX_ registros)",
                "sInfoPostFix":   "",
                "sSearch":        "Buscar:",
                "sUrl":           "",
                "sInfoThousands":  ",",
                "sLoadingRecords": "Cargando...",
                "oPaginate": {
                    "sFirst":    "Primero",
                    "sLast":    "Último",
                    "sNext":    "Siguiente",
                    "sPrevious": "Anterior"
                },
                "oAria": {
                    "sSortAscending":  ": Activar para ordenar la columna de manera ascendente",
                    "sSortDescending": ": Activar para ordenar la columna de manera descendente"
                }
            }
        });
        
        $('#datetimepicker1').datetimepicker({
            locale: 'es',
            allowInputToggle : true,
            sideBySide : true,
            format: 'YYYY/MM/DD HH:mm'
        });
        

        //Flat red color scheme for iCheck
        $('input[type="checkbox"].flat').iCheck({
            checkboxClass: 'icheckbox_flat-blue'
        });
    });
  </script>
</body>
</html>
