<?php

include '../conector.php';
session_start();

if(isset($_SESSION["user"]) && ($_SESSION["tipo"]=='P')){

if($_SESSION["tipo"]=='E'){$cuenta="select estudiante.estudiante_id,estudiante.curso_id,estudiante.vernotas from estudiante where usuario='".$_SESSION["user"]."'	and estudiante.estado_est='A'";}
//if($_SESSION["tipo"]=='P'){$cuenta="select estudiante.estudiante_id,estudiante.curso_id from estudiante where usuario_acud='".$_SESSION["user"]."'	and estudiante.estado_est='A'";}
if($_SESSION["tipo"]=='P'){$cuenta="select estudiante.estudiante_id,estudiante.curso_id,estudiante.vernotas from estudiante where estudiante.estudiante_id=".$_SESSION["estudiante"]." ";}
$res_cuenta=mysql_query($cuenta);
$rs_cta=mysql_fetch_array($res_cuenta);
/*********Verificacion Pension**********/
$select_pagos="select count(*) 
from pagos 
where
estado='D' 
and titulo='P'
and estudiante='".$rs_cta[0]."' "; 

$res_select_pagos=mysql_query($select_pagos);
$rs_pagos=mysql_fetch_array($res_select_pagos);



/*********fin verif pagos*********/
  $class1="class=\"active\"";
  $class2="";
  $act2="";
  $act1=" active ";

 $select_pago="select  	id,
			estudiante,
			titulo,
			descripcion,
			valor,
			fecha,
			fecha_insert,
			estado,
			(select estudiante.nombre from estudiante where estudiante.estudiante_id=pagos.estudiante),
			(select curso.codigo from estudiante,curso where curso.curso_id=estudiante.curso_id and estudiante.estudiante_id=pagos.estudiante)
 			from pagos 
 			where estado in ('D','P') 
 			order by id";
//echo $select_pago;				
/* $res_select_pago=mysql_query($select_pago);
				
					$tbody="<tbody>";
					while($r_sp=mysql_fetch_array($res_select_pago)){
					
					if($r_sp[7]=='P'){
					 $pago="<span class='label label-success'>Pago</span>";
					}else{
					 $pago="<span class='label label-danger'>Debe</span>";
					}
					
					$tbody.="<tr role='row'><td>".$r_sp[8]."</td><td>".$r_sp[2]."</td><td>".$r_sp[3]."</td><td>$ ".number_format($r_sp[4])."</td><td>".$pago."</td><td>".$r_sp[5]."</td><td>&nbsp;</td></tr>";
					}
					$tbody.="</tbody>";*/

if(isset($_POST['val1'])&&!empty($_POST['val1'])){
if($_POST['val1']==3){
$borra_pago="update pagos set estado='A' where id=".$_POST['pago1']." ";
mysql_query($borra_pago)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Pago Anulado
			</div>";
}
 if($_POST['val1']==2){
 	$act_pago="update pagos 
 	set titulo='".$_POST['titulo1']."',
 	descripcion='".$_POST['descripcion1']."',
 	valor=".$_POST['valor1'].",
 	fecha='".$_POST['fecha_p1']."',
 	fecha_act=now(),
 	estado='".$_POST['estado1']."'
 	where id=".$_POST['pago1']." ";


	mysql_query($act_pago)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Pago Actualizado
			</div>";
 }
 if($_POST['val1']==1||$_POST['val1']==2||$_POST['val1']==3){
 
  $select_pago="select  	id,
			estudiante,
			titulo,
			descripcion,
			valor,
			fecha,
			fecha_insert,
			estado,
			(select estudiante.nombre from estudiante where estudiante.estudiante_id=pagos.estudiante),
			(select curso.codigo from estudiante,curso where curso.curso_id=estudiante.curso_id and estudiante.estudiante_id=pagos.estudiante)
 			from pagos 
 			where estudiante='".$rs_cta[0]."'
 			and estado in ('D','P')
 			order by id";
//echo $select_pago;				
if(mysql_query($select_pago)){
 $res_select_pago=mysql_query($select_pago);
 $num_fil=mysql_num_rows($res_select_pago);}
				
					if($num_fil>0){
					$tbody="<tbody>";
					while($r_sp=mysql_fetch_array($res_select_pago)){
					
					if($r_sp[7]=='P'){
					 $pago="<span class='label label-success'>Pagada</span>";
					}else{
					 $pago="<span class='label label-danger'>Debe</span>";
					}
					
					
						
					
					
					
					$tbody.="<tr role='row'><td>".$r_sp[8]."</td><td>".$concept."</td><td>".$r_sp[3]."</td><td>$ ".number_format($r_sp[4])."</td><td>".$pago."</td><td>".$r_sp[5]."</td><td>
					
					<a class='btn btn-primary btn-xs' data-toggle='modal' data-target='#mimodala".$r_sp[0]."' name='".$_POST['buscar1']."' id='".$_POST['buscar1']."' onclick=''>
			                Ver  
				            </a>
					
					
					</td></tr>";
					$empresa="select * from empresa ";
					$rs_empresa=mysql_query($empresa);
					$rs_emp=mysql_fetch_array($rs_empresa);
					
					
					
					$tbody.="<div name='mimodala".$r_sp[0]."' id='mimodala".$r_sp[0]."' class='modal fade bs-example-modal-sm' tabindex='-1' role='dialog' aria-labelledby='mySmallModalLabel' aria-hidden='true'>
					  <div class='modal-dialog modal-md'>
					    <div class='modal-content'>
					      <div class='modal-header'>
						      <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>x</button>
					      		<h4 class='modal-title' id='myLargeModalLabel'>Factura de Pago</h4>
      					      </div>
      					      <div class='modal-body'>";
					
					     //     $select_obs_doc="select * from observacion_docente where planilla=".$_POST['per1']." and estudiante=".$r_sce[0]."   ";
					       //   $res_select_obs_doc=mysql_query($select_obs_doc);
					        //  while($r_sodoc=mysql_fetch_array($res_select_obs_doc)){
if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
							<div>
							<div style='float:left;padding-right:10px'><b>Pagar a: </b><br>".$rs_emp[1]."<br>".$rs_emp[4]."<br><br><b>Concepto </b><br>".$r_sp[3]."</div>
							<div><b>Cliente: </b><br>".$r_sp[8]."<br>Curso: ".$r_sp[9]."<br><br><b>Valor </b><br>$ ".number_format($r_sp[4])."</div>
							</div>
							<div>
								<hr>
							</div>
							<div>
							<div style=''><b>Nro. Factura: </b>".$r_sp[0]."<br><b>Fecha: </b>".$r_sp[5]."<br><b>Estado: </b>".$estado."<br></div>
							</div>
							<div>
								<hr>
							</div>

							<div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='PrintContent(".$r_sp[0].")' >Imprimir</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
							";
					         // }
					$tbody.="
						</div>
					    </div>
					  </div>
					</div>	";	
					
					$tbody.="<div name='mimodalb".$r_sp[0]."' id='mimodalb".$r_sp[0]."' class='modal fade bs-example-modal-sm' tabindex='-1' role='dialog' aria-labelledby='mySmallModalLabel' aria-hidden='true'>
					  <div class='modal-dialog modal-md'>
					    <div class='modal-content'>
					      <div class='modal-header'>
						      <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>x</button>
					      		<h4 class='modal-title' id='myLargeModalLabel'>Editar Pago</h4>
      					      </div>
      					      <div class='modal-body'>";
					
					     //     $select_obs_doc="select * from observacion_docente where planilla=".$_POST['per1']." and estudiante=".$r_sce[0]."   ";
					       //   $res_select_obs_doc=mysql_query($select_obs_doc);
					        //  while($r_sodoc=mysql_fetch_array($res_select_obs_doc)){
						if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
							
							 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Estudiante&nbsp;
							  </div>
							 <div class='' >
							    <input disabled value='".$r_sp[8]."' type='text' id='buscar".$r_sp[0]."' name='buscar".$r_sp[0]."' class='form-control'  style='width:48%;margin-bottom: 10px' >
							 </div>
					
							 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								T&iacute;tulo&nbsp;
							  </div>
							 <div class='input' >
							    <input value='".$r_sp[2]."' id='titulo".$r_sp[0]."' name='titulo".$r_sp[0]."' type='text' class='form-control' placeholder='ej. pago mensualidad' style='width:48%;margin-bottom: 10px'>
							 </div>
			
							<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Descripci&oacute;n &nbsp;
							  </div>
							
							 <div class='input' >
							    <input value='".$r_sp[3]."' id='descripcion".$r_sp[0]."' name='descripcion".$r_sp[0]."' type='text' class='form-control'  placeholder='ej. pago mes de enero' style='width:48%;margin-bottom: 10px'>
							 </div>
							<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Valor &nbsp;
							  </div>
							 <div class='input' >
							    <input value='".$r_sp[4]."' id='valor".$r_sp[0]."' name='valor".$r_sp[0]."' type='text' class='form-control'  placeholder='ej. 100000' style='width:48%;margin-bottom: 10px'>
							 </div>
							<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Estado&nbsp;
							  </div>
							 <div class='input' >
								<select id='estado".$r_sp[0]."' name='estado".$r_sp[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								$sel2='';$sel1='';
			if($r_sp[7]=='D'){$sel1=' selected ';}else{$sel2=' selected ';}
								$tbody.="<option value='D' $sel1 >Debe</option>
									<option value='P' $sel2 >Pago</option>";
									
							$tbody.="</select>
							 </div>
							<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Fecha&nbsp;
							  </div>
							 <div class='input' >
							    <input value='".$r_sp[5]."'  id='fecha_p".$r_sp[0]."' name='fecha_p".$r_sp[0]."' type='date' class='form-control'  style='width:48%;margin-bottom: 10px'>
							 </div>
							
							<div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_pago(".$r_sp[0].",".$_POST['buscar1'].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
							";
					         // }
					$tbody.="
						</div>
					    </div>
					  </div>
					</div>	";	
					
					}
					$tbody.="</tbody>";
 					}else
 					{
 					$men="<div class=\"alert alert-danger\">
		                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
		                    No existen registros para esta busqueda.
					</div>";
 					
 					}
 
 }


}

if(isset($_POST['val2'])&&!empty($_POST['val2'])){

 if($_POST['val2']==1){
  $class1="";
  $class2="class=\"active\"";
  $act1="";
  $act2=" active ";

	$insertar_pago='insert into pagos (estudiante,titulo,descripcion,valor,fecha,fecha_insert,estado)
	values("'.$_POST['buscar2'].'","'.$_POST['titulo2'].'","'.$_POST['descripcion2'].'","'.$_POST['valor2'].'","'.$_POST['fecha_p2'].'",now(),"'.$_POST['estado2'].'"
	)';
//echo $insertar_pago;
	mysql_query($insertar_pago)or die(mysql_error());
	$men="<div class=\"alert alert-success\">
                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
                    Pago Insertado
			</div>";

 }
}


 $select_pago="select  	id,
			estudiante,
			titulo,
			descripcion,
			valor,
			fecha,
			fecha_insert,
			estado,
			(select estudiante.nombre from estudiante where estudiante.estudiante_id=pagos.estudiante),
			(select curso.codigo from estudiante,curso where curso.curso_id=estudiante.curso_id and estudiante.estudiante_id=pagos.estudiante)
 			from pagos 
 			where estudiante='".$rs_cta[0]."'
 			and estado in ('D','P')
 			order by id";
//echo $select_pago;				
if(mysql_query($select_pago)){
 $res_select_pago=mysql_query($select_pago);
 $num_fil=mysql_num_rows($res_select_pago);}
				
					if($num_fil>0){
					$tbody="<tbody>";
					while($r_sp=mysql_fetch_array($res_select_pago)){
					
					if($r_sp[7]=='P'){
					 $pago="<span class='label label-success'>Pagada</span>";
					}else{
					 $pago="<span class='label label-danger'>Debe</span>";
					}
					
					$select_pagos_det="select sum(valor) as valor1 from pagos_detalle where pago=".$r_sp[0]." and estado='A' ";
					$res_select_pagos_det=mysql_query($select_pagos_det);
					$res_pagos=mysql_fetch_array($res_select_pagos_det);
					
					
					if(!isset($res_pagos[0])||$res_pagos[0]==0){$saldo_consulta=$r_sp[4];}
					else{$saldo_consulta=$r_sp[4]-$res_pagos[0];}

					
					 $pago="";
					if($saldo_consulta<=0){$pago="<span class='label label-success'>Pago</span>";}
					if($saldo_consulta==$r_sp[4]){$pago="<span class='label label-danger'>Debe</span>";}
					if($saldo_consulta>0&&$saldo_consulta<$r_sp[4])	{ $pago="<span class='label label-warning'>Abono</span>";}
					
					
					
					
					
						$concept="";
					if($r_sp[2]=='P'){$concept='Pensi&oacute;n';}
					if($r_sp[2]=='L'){$concept='Libros';}					
					if($r_sp[2]=='M'){$concept='Matr&iacute;cula';}					
					if($r_sp[2]=='U'){$concept='Uniformes';}					
					if($r_sp[2]=='O'){$concept='Otro';}	
					
					
					$tbody.="<tr role='row'><td>".$r_sp[8]."</td><td>".$concept."</td><td>".$r_sp[3]."</td><td>$ ".number_format($r_sp[4])."</td>
					<td>$ ".number_format($saldo_consulta)."</td>
					<td>".$pago."</td><td>".$r_sp[5]."</td><td>
					
					<a class='btn btn-primary btn-xs' data-toggle='modal' data-target='#mimodala".$r_sp[0]."' name='".$_POST['buscar1']."' id='".$_POST['buscar1']."' onclick=''>
			                Ver  
				            </a>
					
					
					</td></tr>";
					$empresa="select * from empresa ";
					$rs_empresa=mysql_query($empresa);
					$rs_emp=mysql_fetch_array($rs_empresa);
					
					
					
					$tbody.="<div name='mimodala".$r_sp[0]."' id='mimodala".$r_sp[0]."' class='modal fade bs-example-modal-sm' tabindex='-1' role='dialog' aria-labelledby='mySmallModalLabel' aria-hidden='true'>
					  <div class='modal-dialog modal-md'>
					    <div class='modal-content'>
					      <div class='modal-header'>
						      <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>x</button>
					      		<h4 class='modal-title' id='myLargeModalLabel'>Factura de Pago</h4>
      					      </div>
      					      <div class='modal-body'>";
					
					     //     $select_obs_doc="select * from observacion_docente where planilla=".$_POST['per1']." and estudiante=".$r_sce[0]."   ";
					       //   $res_select_obs_doc=mysql_query($select_obs_doc);
					        //  while($r_sodoc=mysql_fetch_array($res_select_obs_doc)){
if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
							<div>
							<div style='float:left;padding-right:10px'><b>Pagar a: </b><br>".$rs_emp[1]."<br>".$rs_emp[4]."<br><br><b>Descripci&oacute;n </b><br>".$r_sp[3]."</div>
							<div><b>Cliente: </b><br>".$r_sp[8]."<br>Curso: ".$r_sp[9]."<br><br><b>Valor </b><br>$ ".number_format($r_sp[4])."</div>
							</div>
							<div>
								<hr>
							</div>
							<div>
							<div style=''><b>Nro. Factura: </b>".$r_sp[0]."<br><b>Fecha: </b>".$r_sp[5]."<br><b>Estado: </b>".$estado."<br></div>
							</div>
							<div>
								<hr>
							</div>";
							
							$select_detalle="select * from pagos_detalle where pago=".$r_sp[0]."  ";
							$res_select_detalle=mysql_query($select_detalle);
							$num_res=mysql_num_rows($res_select_detalle);
							if($num_res>0){
							
							$tbody.="
							<div class='table-responsive'>";
							while($r_sdet=mysql_fetch_array($res_select_detalle)){
								$tbody.="
									<div>
										Nro. Pago: $r_sdet[0] <br>
										Fecha: ".date("d/m/Y",strtotime(substr($r_sdet[2],0,10)))." <br>
										Valor: $ ".number_format($r_sdet[3])."
									</div>
									<div>
										<hr>
									</div>
									";
							
							}
							$tbody.="
							</div>";
							
							
							}
							
							
							
$tbody.="
							<div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='PrintContent(".$r_sp[0].")' >Imprimir</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
							";
					         // }
					$tbody.="
						</div>
					    </div>
					  </div>
					</div>	";	
					
					$tbody.="<div name='mimodalb".$r_sp[0]."' id='mimodalb".$r_sp[0]."' class='modal fade bs-example-modal-sm' tabindex='-1' role='dialog' aria-labelledby='mySmallModalLabel' aria-hidden='true'>
					  <div class='modal-dialog modal-md'>
					    <div class='modal-content'>
					      <div class='modal-header'>
						      <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>x</button>
					      		<h4 class='modal-title' id='myLargeModalLabel'>Editar Pago</h4>
      					      </div>
      					      <div class='modal-body'>";
					
					     //     $select_obs_doc="select * from observacion_docente where planilla=".$_POST['per1']." and estudiante=".$r_sce[0]."   ";
					       //   $res_select_obs_doc=mysql_query($select_obs_doc);
					        //  while($r_sodoc=mysql_fetch_array($res_select_obs_doc)){
						if($r_sp[7]=='D'){$estado='SIN PAGAR';}else{$estado='PAGADA';}
							$tbody.="
							
							 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Estudiante&nbsp;
							  </div>
							 <div class='' >
							    <input disabled value='".$r_sp[8]."' type='text' id='buscar".$r_sp[0]."' name='buscar".$r_sp[0]."' class='form-control'  style='width:48%;margin-bottom: 10px' >
							 </div>
					
							 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								T&iacute;tulo&nbsp;
							  </div>
							 <div class='input' >
							    <input value='".$r_sp[2]."' id='titulo".$r_sp[0]."' name='titulo".$r_sp[0]."' type='text' class='form-control' placeholder='ej. pago mensualidad' style='width:48%;margin-bottom: 10px'>
							 </div>
			
							<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Descripci&oacute;n &nbsp;
							  </div>
							
							 <div class='input' >
							    <input value='".$r_sp[3]."' id='descripcion".$r_sp[0]."' name='descripcion".$r_sp[0]."' type='text' class='form-control'  placeholder='ej. pago mes de enero' style='width:48%;margin-bottom: 10px'>
							 </div>
							<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Valor &nbsp;
							  </div>
							 <div class='input' >
							    <input value='".$r_sp[4]."' id='valor".$r_sp[0]."' name='valor".$r_sp[0]."' type='text' class='form-control'  placeholder='ej. 100000' style='width:48%;margin-bottom: 10px'>
							 </div>
							<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Estado&nbsp;
							  </div>
							 <div class='input' >
								<select id='estado".$r_sp[0]."' name='estado".$r_sp[0]."' class='form-control' style='width:48%;margin-bottom: 10px'>";
								$sel2='';$sel1='';
			if($r_sp[7]=='D'){$sel1=' selected ';}else{$sel2=' selected ';}
								$tbody.="<option value='D' $sel1 >Debe</option>
									<option value='P' $sel2 >Pago</option>";
									
							$tbody.="</select>
							 </div>
							<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
								Fecha&nbsp;
							  </div>
							 <div class='input' >
							    <input value='".$r_sp[5]."'  id='fecha_p".$r_sp[0]."' name='fecha_p".$r_sp[0]."' type='date' class='form-control'  style='width:48%;margin-bottom: 10px'>
							 </div>
							
							<div><button type=\"button\" class=\"btn btn-primary btn-xs\" onclick='actualiza_pago(".$r_sp[0].",".$_POST['buscar1'].")' >Actualizar</button>
							<button type=\"button\" class=\"btn btn-info btn-xs\" data-dismiss='modal' >Cerrar</button>
							</div>
							";
					         // }
					$tbody.="
						</div>
					    </div>
					  </div>
					</div>	";	
					
					}
					$tbody.="</tbody>";
 					}else
 					{
 					$men="<div class=\"alert alert-danger\">
		                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
		                    No existen registros para esta busqueda.
					</div>";
 					
 					}

echo "
<!DOCTYPE html>
<html lang=\"en\">
  <head>
    <meta charset=\"utf-8\">
    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
    <meta name=\"description\" content=\"\">
    <meta name=\"author\" content=\"\">
    <link rel=\"shortcut icon\" href=\"../assets/ico/favicon.ico\">
<link rel='stylesheet' href='../js/css/jquery-ui-1.9.2.custom.css' />	

    <title>Pagos</title>

    <!-- Bootstrap core CSS -->
    <link href=\"../dist/css/bootstrap.min.css\" rel=\"stylesheet\">

    <!-- Custom styles for this template -->
    <link href=\"../offcanvas.css\" rel=\"stylesheet\">

    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src=\"../assets/js/ie8-responsive-file-warning.js\"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src=\"https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js\"></script>
      <script src=\"https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js\"></script>
    <![endif]-->


    <script>

function crea_pago(){
	if(document.getElementById('buscar').value==''){alert('Debe digitar el nombre');return false;}
		else{
		var mystr = document.getElementById('buscar').value;
		var myarr = mystr.split(' - ');var t_id = myarr[0];
		document.getElementById('buscar2').value=t_id;
		}
	
	if(document.getElementById('titulo').value==''){alert('Debe digitar el titutlo');return false;}
		else{document.getElementById('titulo2').value=document.getElementById('titulo').value}
	
	if(document.getElementById('descripcion').value==''){alert('Debe digitar descripcion');return false;}
		else{document.getElementById('descripcion2').value=document.getElementById('descripcion').value}
	
	if(document.getElementById('valor').value==''){alert('Debe digitar valor');return false;}
		else{document.getElementById('valor2').value=document.getElementById('valor').value}
	
	if(document.getElementById('estado').value==''){}
		else{document.getElementById('estado2').value=document.getElementById('estado').value}
	
	if(document.getElementById('fecha_p').value==''){alert('Debe seleccionar fecha');return false;}
		else{document.getElementById('fecha_p2').value=document.getElementById('fecha_p').value}


	document.getElementById('val2').value=1;
	document.forms['crear_pago'].submit();			
}
function buscar_pago(){

if(document.getElementById('buscar_').value==''){alert('Debe digitar el nombre');return false;}
		else{
		var mystr = document.getElementById('buscar_').value;
		var myarr = mystr.split(' - ');var t_id = myarr[0];
		document.getElementById('buscar1').value=t_id;
		}

	document.getElementById('val1').value=1;
	document.forms['listar_pago'].submit();

}
function actualiza_pago(ide,est){

document.getElementById('buscar1').value=est;
if(document.getElementById('titulo'+ide).value==''){alert('Debe digitar el titutlo');return false;}
		else{document.getElementById('titulo1').value=document.getElementById('titulo'+ide).value}
	
	if(document.getElementById('descripcion'+ide).value==''){alert('Debe digitar descripcion');return false;}
		else{document.getElementById('descripcion1').value=document.getElementById('descripcion'+ide).value}
	
	if(document.getElementById('valor'+ide).value==''){alert('Debe digitar valor');return false;}
		else{document.getElementById('valor1').value=document.getElementById('valor'+ide).value}
	
	if(document.getElementById('estado'+ide).value==''){}
		else{document.getElementById('estado1').value=document.getElementById('estado'+ide).value}
	
	if(document.getElementById('fecha_p'+ide).value==''){alert('Debe seleccionar fecha');return false;}
		else{document.getElementById('fecha_p1').value=document.getElementById('fecha_p'+ide).value}				
	document.getElementById('pago1').value=ide;
	
	document.getElementById('val1').value=2;
	document.forms['listar_pago'].submit();
}
function borra_pago(ide,est){
if (confirm('Esta seguro que desea anular este registro?')) {	

document.getElementById('buscar1').value=est;
document.getElementById('pago1').value=ide;

	document.getElementById('val1').value=3;
	document.forms['listar_pago'].submit();


}
		else{return false;}



}
</script>
    
  </head>

  <body>
    <div class=\"navbar navbar-fixed-top navbar-inverse\" role=\"navigation\">
       <div class=\"container\">
        <div class=\"navbar-header\">
          <button type=\"button\" class=\"navbar-toggle hidden-xs\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">
            <span class=\"sr-only\">Toggle navigation</span>
         
          </button>
         
         
          
          <a  href=\"general.php\" class='hidden-xs' ><img src='../img/logo1.png'  style='margin-top:5px;'></a>
	         <div align='' class='visible-xs'>
		        <a  href=\"general.php\"  ><img src='../img/logo1.png' width='248px' style='margin-top:10px;margin-left:5px'></a>";

if($_SESSION["tipo"]=='P'){
			
echo	"<a href='previo.php' ><span style='float:right;margin-right:10px; margin-top:15px' class='label label-success '> <span class='glyphicon  glyphicon-zoom-in'></span> </span></a>";
					}
echo
		         "<a href=\"../index.php\" ><img src='../img/salir2.png' style='float:right;margin-top:15px;margin-right:10px'></a>
	         </div>

        </div>
      	<a href=\"../index.php\" class='hidden-xs'><img src='../img/salir.png' style='float:right;margin-top:15px'>
 	      	
         </a>

       ";          
if($_SESSION["tipo"]=='P'){
			
				echo	"<a href='previo.php'><span style='float:right;margin-right:10px; margin-top:15px' class='label label-success hidden-xs'>Seleccionar <span class='glyphicon  glyphicon-zoom-in'></span> </span></a>";
					}
echo			"
       <span style='float:right;margin-right:10px; margin-top:15px' class='label label-success hidden-xs'><span class='glyphicon glyphicon-user'></span> ".$_SESSION["user"]."  </span>  
      	
      </div><!-- /.container -->
    </div><!-- /.navbar -->


    <div class=\"container\">

      <div class=\"row row-offcanvas row-offcanvas-left\">

       <div class=\"col-xs-6 col-sm-3 sidebar-offcanvas\" id=\"sidebar\" role=\"navigation\">
          <div class=\"list-group\">";
         if($rs_pagos[0]>0){
            echo "            <a href=\"previo.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-th\"></span> Estudiantes</a>
            <a href=\"pagos.php\" class=\"list-group-item active\"><span class=\"glyphicon glyphicon-list\"></span> Pagos</a>";
         }
         else{ 
           echo "<a href=\"general.php\" class=\"list-group-item \" data-rel='popover' data-content='Dashboard' data-original-title><span class=\"glyphicon glyphicon-home\"></span> General</a>
            <a href=\"estudiantes.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-th\"></span> Estudiantes</a>
            <a href=\"docentes.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-user\"></span> Docentes</a>
            <a href=\"horario.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Horario</a>
            <a href=\"planilla.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Calificaciones</a>";            if($rs_cta[2]=='1'){echo "<a href=\"reportes.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Informes</a>";}
echo            "
            <a href=\"planilla_obs.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Control Disciplina</a>
            <a href=\"pagos.php\" class=\"list-group-item active\"><span class=\"glyphicon glyphicon-list\"></span> Pagos</a>                       
       ";
	}
          
          
echo    "</div>
        </div><!--/span-->

        <div class=\"col-xs-12 col-sm-9\">
          <p class=\"pull-left visible-xs\">
            <button type=\"button\" class=\"btn btn-primary btn-xs\" data-toggle=\"offcanvas\">menu</button>
          </p>
    
	<div class=\"panel panel-default\">
	<br>";
echo $men;	
echo	      "<!-- Nav tabs -->
	<ul class=\"nav nav-tabs\">
		<li >&nbsp;</li>
	  <li $class1 ><a href=\"#home\" data-toggle=\"tab\">Gesti&oacute;n Pagos</a></li>

	</ul>
	
	<!-- Tab panes -->

	<div class=\"tab-content\">
	<div class=\"tab-pane fade in $act2 \" id=\"profile\">
		<form name='crear_pago' id='crear_pago' method='post' action='pagos.php#profile' target='' enctype='multipart/form-data'>
		<input type='hidden' name='val2' id='val2' value='".$val2."'>	
		<input type='hidden' name='buscar2' id='buscar2' value='".$buscar2."'>	
		<input type='hidden' name='titulo2' id='titulo2' value='".$titulo2."'>	
		<input type='hidden' name='descripcion2' id='descripcion2' value='".$descripcion2."'>			
		<input type='hidden' name='valor2' id='valor2' value='".$valor2."'>			
		<input type='hidden' name='estado2' id='estado2' value='".$estado2."'>
		<input type='hidden' name='fecha_p2' id='fecha_p2' value='".$fecha_p2."'>				
		
		<div class=\"page\">
			<fieldset>
				<legend>
					<br><span class=\"glyphicon glyphicon-plus\"></span> Crear Nuevo Pago          
				</legend>			
			</fieldset>
		
		
		 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Estudiante&nbsp;
		  </div>
		 <div class='' >
		    <input type='text' id='buscar' name='buscar' class='form-control' value='' style='width:48%;margin-bottom: 10px' onclick='this.value=\"\"'>
		 </div>

		 <div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			T&iacute;tulo&nbsp;
		  </div>
		 <div class='input' >
		    <input id='titulo' name='titulo' type='text' class='form-control' placeholder='ej. pago mensualidad' style='width:48%;margin-bottom: 10px'>
		 </div>
		<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Descripci&oacute;n &nbsp;
		  </div>
		 <div class='input' >
		    <input id='descripcion' name='descripcion' type='text' class='form-control'  placeholder='ej. pago mes de enero' style='width:48%;margin-bottom: 10px'>
		 </div>
		<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Valor &nbsp;
		  </div>
		 <div class='input' >
		    <input id='valor' name='valor' type='text' class='form-control'  placeholder='ej. 100000' style='width:48%;margin-bottom: 10px'>
		 </div>
		<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Estado&nbsp;
		  </div>
		 <div class='input' >
			<select id='estado' name='estado' class='form-control' style='width:48%;margin-bottom: 10px'>
				<option value='D'>Debe</option>
				<option value='P'>Pago</option>
			</select>
		 </div>
		<div class='input' style='float:left;width: 140px;padding-top: 5px;padding-left: 10px;text-align: left;' >
			Fecha&nbsp;
		  </div>
		 <div class='input' >
		    <input id='fecha_p' name='fecha_p' type='date' class='form-control'  style='width:48%;margin-bottom: 10px'>
		 </div>


		<fieldset>
		<legend>
					<br>
					
		</legend>	
			<button type='button' class='btn btn-info' onclick='crea_pago()'> Crear Pago</button>     
			<input type='reset' class='btn' value='Borrar'>
						
		</fieldset>
			
			<br>
		</div>
	</form>
</div>

<div class=\"tab-pane fade in $act1 \" id=\"home\">
	<form name='listar_pago' id='listar_pago' method='post' action='pagos.php' target=''>
	<div class=\"page\">
	

	<input type='hidden' name='val1' id='val1' value='".$val1."'>	
<input type='hidden' name='buscar1' id='buscar1' value='".$buscar1."'>	
		<input type='hidden' name='titulo1' id='titulo1' value='".$titulo1."'>	
		<input type='hidden' name='descripcion1' id='descripcion1' value='".$descripcion1."'>			
		<input type='hidden' name='valor1' id='valor1' value='".$valor1."'>			
		<input type='hidden' name='estado1' id='estado1' value='".$estado1."'>
		<input type='hidden' name='fecha_p1' id='fecha_p1' value='".$fecha_p1."'>
		<input type='hidden' name='pago1' id='pago1' value='".$pago1."'>		
			
	<input type='hidden' name='cur1' id='cur1' value='".$cur1."'>	
		<fieldset>
			<legend><br><span class=\"glyphicon glyphicon-th-list\"></span> 
				Lista de Pagos
			</legend>			
		</fieldset>
	</div>

	<fieldset>
	<div class='table-responsive'>
	<table class='table table-striped table-bordered '>
		<thead>
			<tr role='row'>
				<th>Estudiante</th>
				<th>Concepto</th>				
				<th>Descripci&oacute;n</th>				
				<th>Valor</th>				
				<th>Saldo</th>																
				<th>Estado</th>								
				<th>Fecha</th>				
				<th>Opciones</th>				
			</tr>
		</thead>";
		
echo $tbody;
echo	"
	</div>
	</table>
	</fieldset>
	
	
	
	</form>

</div>
 
         
        </div><!--/span-->

       
      </div><!--/row-->

</div><!--/row-->

      </div><!--/row--><hr><footer><p>Todos los derechos reservados - Copyright &copy; 2024</p></footer>
    </div><!--/.container-->

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src=\"https://code.jquery.com/jquery-1.10.2.min.js\"></script>
  <script src=\"../js/jquery-ui-1.10.3.custom.js\"></script>
  
    <script src=\"../dist/js/bootstrap.min.js\"></script>
    <script src=\"../offcanvas.js\"></script>
<script>
      $(function() {
	$( \"#buscar\" ).autocomplete(
	{
		 source:'../source.php',		 
		 minLength: 3
	})
}); 
$(function() {
	$( \"#buscar_\" ).autocomplete(
	{	 source:'../source.php',		 
		 minLength: 3	})
}); 

function PrintContent(iden)
{
var DocumentContainer = document.getElementById('mimodala'+iden);
var WindowObject = window.open('', 'PrintWindow',
'width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes');
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.close();
//WindowObject.focus();
  if (WindowObject.print()){ 
                WindowObject.close(); 
        }else{ 
                WindowObject.close(); 
        } 

//WindowObject.print();
//WindowObject.close();
}
</script>
  </body>
</html>
";
}else{
echo "<div align='center'>Debe registrase para usar la aplicaci&oacute;n <a href='../index.php' > Registrar</a></div>";
}
?>