<?
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/Movimiento.class.php"); $objf = new Movimiento();

if($obju->BuscarPorUsuario($_SESSION['usuario']))
{
   $idusuario = $obju->getidusuario();
   $usuario = $obju->getusuario();
   $tipouser = $obju->gettipo();
}

/*
$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();
	 $ocupacion = $obja->getocupacion();
	 $gradoins = $obja->getgradoins();
	 $estadocivil = $obja->getestadocivil();
	 $fecha_afilia = $obja->getfecha_afilia();
	 $sangre = $obja->getsangre();
	 $foto = $obja->getfoto();
   }*/
?>

<!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.tipo.value==""){
		 f.tipo.focus();
		 return false;
	}
	if(f.fecha.value==""){
		 f.fecha.focus();
		 return false;
	}

    if(f.proveedor.value==""){
		 f.proveedor.focus();
		 return false;
	}
	 if(f.dniruc.value==""){
		 f.dniruc.focus();
		 return false;
	}
	 if(f.numdoc.value==""){
		 f.numdoc.focus();
		 return false;
	}
	 if(f.concepto.value==""){
		 f.concepto.focus();
		 return false;
	}
	 if(f.monto.value==""){
		 f.monto.focus();
		 return false;
	}
	
/*	if(f.file.value==""){
		 f.file.focus();
		 return false;
	}*/
		
		   f.action='controladores/RendicionController.php';
		   f.submit();
		   return true;
		 
}

function imprime(id)
		{
		  window.open("recibo.php?idmov="+id,"","fullscreen=no, height=550,width=800,left=250,top=100,resizable = yes,scrollbars=yes,toolbar = no,status = no");
		}
	</script>
</head>
<body>
<div class="container">
  <div class="row"></div>
  
  
  
          <div class="col-md-12">
		  
        <h4>Datos de Ingresos y Gastos 
		<button class="btn btn-success btn-sm" data-title="AGREGAR" data-toggle="modal" data-target="#nuevo" ><span class="glyphicon glyphicon-plus"></span>Agregar</button>
		<a href="contenido.php"  type="button" class="btn btn-sm btn-danger"><i class="glyphicon glyphicon-log-out"></i></a></h4>
        <div class="table-responsive">

                
              <table id="mytable" class="table table-bordred table-striped">
                   
                   <thead>
                     <tr><th width="6%">ID</th>
                       <th width="12%">Tipo</th>
                       <th width="10%">Fecha</th>
                       <th width="12%">DNI/RUC</th>
                       <th width="13%">Proveedor</th>
                       <th width="9%">N° Comp. </th>
                      
                       <th width="12%">Concepto</th>
                       <th width="6%">Monto</th>
                       <th width="6%">Ver Doc </th>
                       <td width="1%"></thead>
    <tbody>
    <?
	  $lista = $objf->ListaTotal();
	  for($i=0;$i<count($lista); $i++)
	  {
	?>
    <tr>
    <td><a href="javascript:imprime(<?=$lista[$i]["idmov"];?>)"><?=$lista[$i]["idmov"];?></a></td>
    <td><?=$lista[$i]["tipo"];?></td>
    <td><?=$lista[$i]["fecha"];?></td>
    <td><?=$lista[$i]["dniruc"];?></td>
    <td><?=$lista[$i]["proveedor"];?></td>
    <td><?=$lista[$i]["numdoc"];?></td>
    <td><?=$lista[$i]["concepto"];?></td>
    <td><?=$lista[$i]["monto"];?></td>
	<td><a href="fotorendicion/<?=$lista[$i]["foto"];?>" >Archivo </a></td>
	<td><a href="controladores/RendicionController.php?ida=<?=$lista[$i]["idmov"];?>&txtpara=E" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a></td>
    </tr>
   <? 
       if($lista[$i]["tipo"]=="INGRESO")
	   {
	      $si = $si + $lista[$i]["monto"];
	   }else{
	   		  $se = $se + $lista[$i]["monto"];
	        }
			
			$total = $si - $se;
   } 
   echo "Total en cuenta: ".$total;
   ?> 
    </tbody>
</table>

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

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


<form name="form2" id="formularioaenviar2" action="" method="post" enctype="multipart/form-data">
<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 Movimiento</h4>
      	  </div>
          <div class="modal-body">
          <div class="form-group">
        Tipo:<select name="tipo" class="form-control">
				<option value="INGRESO">INGRESO</option>
				<option value="EGRESO">EGRESO</option>
		     </select>
        </div>
        <div class="form-group">
		 <div class="row">
		   <div class="col-md-6">
        	Fecha:
        	<input class="form-control " type="text" name="fecha"  placeholder="Fecha">
		   </div>
		   <div class="col-md-6">
		    Proveedor/Acreedor<input class="form-control " type="text" name="proveedor" placeholder="Proveedor">
		    </div>
		   </div>
        </div>
		<div class="form-group">
		<div class="row">
		   <div class="col-md-4">
        	DNI/RUC
        	<input class="form-control " type="text" name="dniruc" placeholder="DNI/RUC">
		   </div>		   
		   <div class="col-md-4">
		   Nro Doc.
        	<input class="form-control " type="text" name="numdoc" placeholder="Nro Documento">
		   </div>
		   </div>
        </div>
		
		<div class="form-group">
        Concepto
        <input class="form-control " type="text" name="concepto" placeholder="Concepto">
        </div>
		<div class="form-group">
        Monto S/.
        <input class="form-control " type="text" name="monto" placeholder="Monto S/.">
        </div>
		<div class="form-group">
        Foto
        <input name="file" type="file">
		<input name="txtpara" type="hidden" value="R">
		 <input name="idusuario" type="hidden" value="<?=$idusuario;?>">
		 <input type="hidden" name="MAX_FILE_SIZE" value="4000000">
        </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>
        </div>
    <!-- /.modal-content --> 
  </div>
      <!-- /.modal-dialog --> 
    </div>
  </form> 
    
    
    
    <div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true">
    <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>
