<?
session_start();
if(!isset($_SESSION['usuario']))
{
 	echo "<script languaje='JavaScript'>";       
	echo "parent.location.href='login.php'; ";
	echo "</script>";
}
include ("clases/Usuario.class.php"); $obju = new Usuario();
include ("clases/Afiliado.class.php"); $obja = new Afiliado();
include ("clases/Familiar.class.php"); $objf = new Familiar();
include ("clases/Ubigeo.class.php"); $objubi = new Ubigeo();

$idafi = $_REQUEST['ida'];
if($obja->BuscarPorCodigo($idafi))
   {
     $dni = $obja->getdni()."/".$obja->getruc();;
     $nombres = $obja->getnombres();
	 $apellidos = $obja->getapepat()." ".$obja->getapemat();
	 $fechanac = $obja->getfechanac();
	 $lugarnac = $obja->getlugarnac();
	 if($objubi->BuscarPorCodigo($lugarnac))
	  {
	     $nombre = $objubi->getnombre();
	   }
	 $ocupacion = $obja->getocupacion();
	 $gradoins = $obja->getgradoins();
	 $estadocivil = $obja->getestadocivil();
	 $fecha_afilia = $obja->getfecha_afilia();
	 $sangre = $obja->getsangre();
	 $foto = $obja->getfoto();
	 $dom = $obja->getdomicilio();
   }
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <!-- This file has been downloaded from Bootsnipp.com. Enjoy! -->
    <title>Simple User Profile  - Bootsnipp.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="media/css/bootstrap.css">
	<link rel="stylesheet" href="media/css/bootstrap.min.css">
	<link rel="stylesheet" href="media/css/bootstrap-theme.css">
	<link rel="stylesheet" href="media/css/bootstrap-theme.min.css">
	<link rel="stylesheet" href="media/css/dataTables.bootstrap.min.css">
	<link rel="stylesheet" href="media/css/fixedHeader.bootstrap.min.css">
	<link rel="stylesheet" href="media/css/responsive.bootstrap.min.css">
	 <script src="media/js/jquery-1.10.2.js"></script>
	<script src="media/js/jquery.dataTables.min.js"></script>
	<script src="media/js/dataTables.bootstrap.min.js"></script>
	<script src="media/js/dataTables.fixedHeader.min.js"></script>
	<script src="media/js/dataTables.responsive.min.js"></script>
	<script src="media/js/responsive.bootstrap.min.js"></script>
	
	<script src="media/js/jquery.min.js"></script>
    <script src="media/js/bootstrap.min.js"></script>
	<script>
function guardar(f)
{   if(f.dni.value==""){
		 f.dni.focus();
		 return false;
	}
	if(f.nombres.value==""){
		 f.nombres.focus();
		 return false;
	}

    if(f.fechanac.value==""){
		 f.fechanac.focus();
		 return false;
	}
	
	if(f.parentesco.value==""){
		 f.parentesco.focus();
		 return false;
	}
	if(f.sangre.value==""){
		 f.sangre.focus();
		 return false;
	}	
	
		   f.action='controladores/FamiliarController.php';
		   f.submit();
		   return true;
		 
}
	</script>
</head>
<body>
<div class="container">
      <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xs-offset-0 col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad" >
   
   
          <div class="panel panel-info">
            <div class="panel-heading">
              <h3 class="panel-title">Mis Datos de Afiliado </h3>
            </div>
            <div class="panel-body">
              <div class="row">
                <div class="col-md-3 col-lg-3 " align="center"> <img alt="User Pic" src="fotos/<?=$foto;?>" class="img-circle img-responsive"> </div>
                
                <!--<div class="col-xs-10 col-sm-10 hidden-md hidden-lg"> <br>
                  <dl>
                    <dt>DEPARTMENT:</dt>
                    <dd>Administrator</dd>
                    <dt>HIRE DATE</dt>
                    <dd>11/12/2013</dd>
                    <dt>DATE OF BIRTH</dt>
                       <dd>11/12/2013</dd>
                    <dt>GENDER</dt>
                    <dd>Male</dd>
                  </dl>
                </div>-->
                <div class=" col-md-9 col-lg-9 "> 
                  <table class="table table-user-information">
                    <tbody>
                      <tr>
                        <td>DNI/RUC N° :</td>
                        <td><?=$dni;?></td>
                      </tr>
                      <tr>
                        <td>Nombres:</td>
                        <td><?=$nombres;?></td>
                      </tr>
                      <tr>
                        <td>Apellidos </td>
                        <td><?=$apellidos;?></td>
                      </tr>
                   
                         <tr>
                      <tr>
                        <td>Fecha Nac. </td>
                        <td><?=$fechanac;?></td>
                      </tr>
                        <tr>
                        <td>Lugar Nac. </td>
                        <td><?=$nombre;?></td>
                      </tr>
                      <tr>
                        <td>Ocupación</td>
                        <td><a href="#">
                          <?=$ocupacion;?>
                        </a></td>
                      </tr>
                      <tr>
                        <td>Grado de Instrucción </td>
                        <td><?=$gradoins;?></td>
                      </tr>
                      <tr>
                        <td>Estado civil </td>
                        <td><?=$estadocivil;?></td>
                      </tr>
                      <tr>
                        <td>Fecha Afiliación </td>
                        <td><?=$fecha_afilia;?></td>
                      </tr>
                    <td>Grupo Sangre</td>
                        <td><?=$sangre;?></td>
                           
                      </tr>  <tr>
                          <td>Domicilio</td>
                          <td><?=$dom;?></td>
                        </tr>
                     
                    </tbody>
                  </table>
                  
                <!--  <a href="#" class="btn btn-primary">My Sales Performance</a> -->
                </div>
              </div>
            </div>
                 <div class="panel-footer">
                       <a data-original-title="Broadcast Message" data-toggle="tooltip" type="button" class="btn btn-sm btn-primary" style="visibility:hidden"><i class="glyphicon glyphicon-envelope"></i></a>
                        <span class="pull-right">
                            <a href="perfiledit.php?ida=<?=$idafi;?>" data-original-title="Editar" data-target="#nuevo" class="btn btn-sm btn-warning"><i class="glyphicon glyphicon-edit"></i></a>
                            <a href="contenido.php" data-original-title="Cerrar" data-toggle="tooltip" type="button" class="btn btn-sm btn-danger"><i class="glyphicon glyphicon-log-out"></i></a>
                        </span>
            </div>
            
          </div>
        </div>
  </div>
  
  
  
          <div class="col-md-12">
        <h4>Datos Familiares <button class="btn btn-success btn-xs" data-title="AGREGAR" data-toggle="modal" data-target="#nuevo" ><span class="glyphicon glyphicon-plus"></span>Agregar</button> </h4>
        <div class="table-responsive">

                
              <table id="mytable" class="table table-bordred table-striped">
                   
                   <thead>
                   <th>Nombres y Apellidos </th>
                    <th>DNI</th>
                     <th>Fecha Nac. </th>
                     <th>Parentesco</th>
                     <th>Grupo Sangre </th>
                      </thead>Accion
    <tbody>
    <?
	  $lista = $objf->ListaPorIdafiliado($idafi);
	  for($i=0;$i<count($lista); $i++)
	  {
	?>
    <tr>
    <td><?=$lista[$i]["nombres"];?></td>
    <td><?=$lista[$i]["dni"];?></td>
    <td><?=$lista[$i]["fechanac"];?></td>
    <td><?=$lista[$i]["parentesco"];?></td>
    <td><?=$lista[$i]["sangre"];?></td>
	<td><a href="controladores/FamiliarController.php?ida=<?=$lista[$i]["idafiliado"];?>&idf=<?=$lista[$i]["idfamiliar"];?>&txtpara=E" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a></td>
    </tr>
   <? } ?> 
    </tbody>
</table>

<div class="clearfix"></div>

                
            </div>
            
        </div>
	</div>
</div>

<form name="form2" id="formularioaenviar2" action="" method="post">
<div class="modal fade" id="nuevo" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true">
      <div class="modal-dialog">
    <div class="modal-content">
          <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
        <h4 class="modal-title custom_align" id="Heading">Registrar Familiar</h4>
      </div>
          <div class="modal-body">
          <div class="form-group">
        DNI:<input class="form-control " type="text" name="dni" placeholder="DNI">
        </div>
        <div class="form-group">
        Nombres y apellidos
        <input class="form-control " type="text" name="nombres" placeholder="Nombres y Aperllidos">
        </div>
		<div class="form-group">
        Fecha Nac.
        <input class="form-control " type="text" name="fechanac" placeholder="fecha Nac">
        </div>
        <div class="form-group">
        <select name="parentesco" class="form-control">
						    <option value="">Parentesco</option>
							<option value="HIJO(A)">HIJO(A)</option>
							<option value="MADRE">MADRE</option>
							<option value="PADRE">PADRE</option>
							<option value="HERMANO(A)">HERMANO(A)</option>
                    </select>
    
        
        </div>
		<div class="form-group">
		<input type="text" name="sangre"  class="form-control" placeholder="Grupo sangre">
		<input name="txtpara" type="hidden" value="R"><input name="idafiliado" type="hidden" value="<?=$idafi;?>">
		</div>
      </div>
          <div class="modal-footer ">
        <button type="button" class="btn btn-warning btn-lg" style="width: 100%;" onClick="guardar(this.form);"><span class="glyphicon glyphicon-ok-sign"></span> Guardar</button>
      </div>
        </div>
    <!-- /.modal-content --> 
  </div>
      <!-- /.modal-dialog --> 
    </div>
  </form>  
    
    
    <div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true">
      <div class="modal-dialog">
    <div class="modal-content">
          <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
        <h4 class="modal-title custom_align" id="Heading">Delete this entry</h4>
      </div>
          <div class="modal-body">
       
       <div class="alert alert-danger"><span class="glyphicon glyphicon-warning-sign"></span> Are you sure you want to delete this Record?</div>
       
      </div>
        <div class="modal-footer ">
        <button type="button" class="btn btn-success" ><span class="glyphicon glyphicon-ok-sign"></span> Yes</button>
        <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> No</button>
      </div>
        </div>
  
</div>



<script type="text/javascript">
$(document).ready(function() {
    var panels = $('.user-infos');
    var panelsButton = $('.dropdown-user');
    panels.hide();

    //Click dropdown
    panelsButton.click(function() {
        //get data-for attribute
        var dataFor = $(this).attr('data-for');
        var idFor = $(dataFor);

        //current button
        var currentButton = $(this);
        idFor.slideToggle(400, function() {
            //Completed slidetoggle
            if(idFor.is(':visible'))
            {
                currentButton.html('<i class="glyphicon glyphicon-chevron-up text-muted"></i>');
            }
            else
            {
                currentButton.html('<i class="glyphicon glyphicon-chevron-down text-muted"></i>');
            }
        })
    });


    $('[data-toggle="tooltip"]').tooltip();

    $('button').click(function(e) {
        e.preventDefault();
      //  alert("This is a demo.\n :-)");
    });
});
</script>
</body>
</html>
