<?php
include("../scripts/connect.php");
   $conexion=conecta_default();
   
   include_once("../scripts/session.php");
   //Validar Session

    $sesion=new Sesion("","","");/*Se crea un objeto nuevo con el privilegio necesario para la pag. actual*/

    if(!$sesion->isValida("4")){ /*Sesion invalida*/

	 header("Location: ../index.php?err=NoSesion");

    }/*no hay sesion*/

    else{

       $dato=explode("|",$_SESSION['usuario']);
       $sesion->setDatos($dato[0],$dato[1],$dato[2]);
       $sesion->setSesion();

    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
extract($_POST);   
if(@$parte2!="Buscar"){
    
echo "<script language='JavaScript1.2' type='text/javascript'>

function CadenaVacia(cadena) {
if (cadena.length==0){
	return true;
	}
else {
	return false;
	}
}

function CadenaVaciaBlancos(cadena) {
var salida='';
for (var i=0;i<cadena.length;i++) {
	if (cadena.substring(i,i+1)!=' ')
		salida=salida+cadena.substring(i,i+1);
	}
if (salida.length==0){
	return true;
	}
else {
	return false;
	}
}

function valida(e)
{
	if (CadenaVaciaBlancos(e.questrfc.value)){
 	alert('Escribe el RFC por favor');
 	e.questrfc.select();
 	return false;
	}
	
	if (e.questrfc.value.length < 10)
	{
	 alert('Revisa el RFC por favor, debe contener 10 caracteres');
 	 e.questrfc.select();
 	 return false;	
	}
}

</script>";

echo "<center><form name='quest' action='apartados.php' method='post'>"
    . "<label><b>Escribe RFC a buscar: </b></label><br><br>"
    . "<label style='color:#5C3C12'>RFC Distribuidor:</label>&nbsp;"
    . "<input type='text' size='14' maxlength='10' name='questrfc' value='' style='font-family: Times New Roman;text-transform:uppercase;' /><br><br>"
    . "<input type='submit' name='parte2' value='Buscar' onclick='return valida(this.form)'><br>"
    . "</form></center>";
}
else{
    echo "<script language='JavaScript' type='text/javascript'>"
    . "window.onload = function grrr() {
for(var i=0;i<199;i++){
var e=document.getElementById('add_abono'+i);
var w=document.getElementById('restante'+i).innerHTML;
var a=document.getElementById('add_abonoD'+i);
var s=document.getElementById('restanteD'+i).innerHTML;
var f=document.getElementById('asigtextD'+i).value;
var g=document.getElementById('asigbotonD'+i);
var x=document.getElementById('asigtext'+i).value;
var y=document.getElementById('asigboton'+i);
var j=document.getElementById('regalos'+i);
var u=document.getElementById('regalosD'+i);

if(w=='$ 0'){
e.disabled=true;
j.style.visibility='visible';}
else{
e.disabled=false;
j.style.visibility='hidden';}


if(x!='---'){
y.disabled=true;
x.disabled=true;}
else
y.disabled=false;
      

if(s=='$ 0'){
a.disabled=true;
u.style.visibility='visible';;}
else{
a.disabled=false;
u.style.visibility='hidden';;}


if(f!='---'){
g.disabled=true;
f.disabled=true;}
else
g.disabled=false;

}
}
"
    . "</script>";
    echo "<h2>Datos</h2>";
    $liquidT="";
    $tipohabT="";
    $precio_hab=0;
    $tipopagoT="";
    $id_abonosin=0;
    $liquidT2="";
    $tipohabT2="";
    $tipopagoT2="";
    $mc1="select id_inver,nombre,appat,apmat from inversionista where rfc='$questrfc'";
    $mh1=mysql_query($mc1) or die("Error 0: ".mysql_error());
    
  if(mysql_affected_rows()){ 
  $mq1=mysql_fetch_object($mh1);
  $id_inv=$mq1->id_inver;
  $rfcin=$questrfc;
  $name1=$mq1->nombre;
  $apep=$mq1->appat;
  $apem=$mq1->apmat;
  $rowi=0;
  $mc2="select * from Apartado where rfc='$rfcin'";
  $mh2=mysql_query($mc2)or die("Error 2: ".msql_error());
  while($mq2=mysql_fetch_object($mh2)){
      $idAP=$mq2->id_ap;
      $tipohab=$mq2->tipo_hab;
      $conce=$mq2->concepto;
      $fecha_aparta=$mq2->fecha_ap;
      if($tipohab==1){
      $tipohabT="Sencilla";
      $precio_hab=1500;
      }
      else{
      $tipohabT="Doble";
      $precio_hab=3500;
      }
   
   echo "<center><table border=5 cellspadding='2' bgcolor='#ffccff'><tbody><tr>"
     . "<th bgcolor='coffee'>RFC</th><th bgcolor='coffee'>Nombre</th><th bgcolor='coffee'>Concepto</th><th bgcolor='coffee'>Apartado N°</th><th bgcolor='coffee'>Tipo Habitación</th><th bgcolor='coffee'>Fecha de Apartado</th></tr>"
             . "<tr>"
             . "<td>$rfcin</td>"
             . "<td>$name1 $apep $apem</td>"
             . "<td>$conce</td>"
             . "<td>$idAP</td>"
             . "<td>Habitacion $tipohabT</td>"
             . "<td>$fecha_aparta</td>"
             . "</tr>"
             . "</tbody></table>"; 
   echo "<h2>Cuartos Reservados</h2>";
   $mc3="select * from abono_evento where id_ap=$idAP";
   $mh3=mysql_query($mc3) or die("Error 3: ".mysql_error());
while($mq3=mysql_fetch_object($mh3)){echo "<table border=3><tbody><tr>"
     . "<th bgcolor='coffee'>Cuarto N°</th><th bgcolor='coffee'>Asignar a</th><th bgcolor='coffee'>Ultimo Abono</th><th bgcolor='coffee'>Abono</th><th bgcolor='coffee'>Tipo de Pago</th><th bgcolor='coffee'>Restante</th><th bgcolor='coffee'>Liquidado</th><th bgcolor='coffee'>Fecha de Liquidado</th><th bgcolor='coffee'>Abonar</th><th bgcolor='coffee'>Historial</th></tr>";
  
    $id_abonosin=$mq3->id_abono;
      $liquid=$mq3->liquidado;
      if($liquid==1){
      $liquidT="SI";
      $fechaLiq=$mq3->fecha_liquid;
      }
      else{
      $liquidT="NO";
      $fechaLiq="---";
      }
      $liquid2=$mq3->liquidado2;
      if($liquid2==1){
      $liquidT2="SI";
      $fechaLiq2=$mq3->fecha_liquid2;
      }
      else{
      $liquidT2="NO";
      $fechaLiq2="---";
      }
      
      $Aname=$mq3->asignado_a;
      if($Aname==""){$Aname="---";}
      $Aname2=$mq3->asignado_a2;
      if($Aname2==""){$Aname2="---";}
      
      $tipopago=$mq3->tipo_pago;
      if($tipopago==0)$tipopagoT="Efectivo";
      if($tipopago==1)$tipopagoT="Depósito";
      if($tipopago==2)$tipopagoT="Tarjeta";
      if($tipopago==3)$tipopagoT="Voucher";
      if($tipopago==4)$tipopagoT="Regalías";
      if($tipopago==5)$tipopagoT="Por Pagar";
      $tipopago2=$mq3->tipo_pago2;
      if($tipopago2==0)$tipopagoT2="Efectivo";
      if($tipopago2==1)$tipopagoT2="Depósito";
      if($tipopago2==2)$tipopagoT2="Tarjeta";
      if($tipopago2==3)$tipopagoT2="Voucher";
      if($tipopago2==4)$tipopagoT2="Regalías";   
      if($tipopago2==5)$tipopagoT2="Por Pagar";
     
       $fr="select transacciones.idtransacciones from inversionista inner join transacciones on inversionista.id_inver = transacciones.inversionista_id_inver where transacciones.tipostr_idtipostr=38 and inversionista.id_inver='$id_inv'and transacciones.fechae='$fechaLiq'";
       $fgr=mysql_query($fr) or die ("error fr: la cagaste en la transaccion porque ".mysql_error());
       echo $fgr;
     if($tipohab==2){
         echo "<tr>"
             . "<td>$rowi</td>"
              . "<td id=asigname><form action='abonos_eventos_p1.php' target='xyz' onsubmit='abrir('xyz');return false;' method='post'>"
              . "<input type='text' id='asigtext$rowi' name='name' value='$Aname' />"
              . "<input type='hidden' name='row' value='$rowi' />"
              . "<input type='hidden' name='idABc' value='$id_abonosin' />"
              . "<input type='submit' id='asigboton$rowi' value='>' />"
              . "</form></td>"
              . "<td>$mq3->fecha_abono</td>"
              . "<td>$ $mq3->abono</td>"
              . "<td>$tipopagoT</td>"
              . "<td id='restante$rowi'>$ $mq3->restante</td>"
              . "<td>$liquidT</td>"
              . "<td>$fechaLiq</td>"
              . "<td><form name='agregar' action='abonos_evento2.php' method='post' target='xyz' onsubmit='abrir(\"xyz\");return false;'>"
              . "<input type='hidden' name='id_AB' value='$id_abonosin' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='submit' id='add_abono$rowi' value='Abonar a este cuarto' />"
              . "</form></td>"
              . "<td><form name='detalles' action='abonos_eventoH.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
              . "<input type='hidden' name='id_AB' value='$id_abonosin' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='submit' id='story_abono$rowi' value='Historial de pagos' />"
              . "</form></td>"
              . "<td id='regalos$rowi'><form action='abonos_eventos_p3.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
              . "<input type='hidden' name='monto' value='0' />"
              . "<input type='hidden' name='restc' value='0' />"
              . "<input type='hidden' name='fecha_i' value='$fechaLiq' />"
              . "<input type='hidden' name='opc' value='0' />"
              . "<input type='hidden' name='entrega' value='$dato[0]' />"
              . "<input type='hidden' name='idABc' value='$id_abonosin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "</form></td>"
                 . "<tr><td></td>"
                 . "<td id=asigname><form action='abonos_eventos_p1D.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
                 . "<input type='text' id='asigtextD$rowi' name='name' value='$Aname2' />"
                 . "<input type='hidden' name='row' value='$rowi' />"
                 . "<input type='hidden' name='idABc' value='$id_abonosin' />"
                 . "<input type='submit' id='asigbotonD$rowi' value='>' />"
                 . "</form></td>"
                 . "<td>$mq3->fecha_abono2</td>"
                 . "<td>$ $mq3->abono2</td>"
                 . "<td>$tipopagoT2</td>"
                 . "<td id='restanteD$rowi'>$ $mq3->restante2</td>"
                 . "<td>$liquidT2</td>"
                 . "<td>$fechaLiq2</td>"
                 . "<td><form name='agregar' action='abonos_evento2D.php' method='post' target='xyz' onsubmit='abrir(\"xyz\");return false;'>"
                 . "<input type='hidden' name='id_AB2' value='$id_abonosin' />"
                 . "<input type='hidden' name='rfck' value='$rfcin' />"
                 . "<input type='hidden' name='idAPk' value='$idAP' />"
                 . "<input type='submit' id='add_abonoD$rowi' value='Abonar a este cuarto' />"
                 . "</form></td>"
                 . "<td><form name='detalles' action='abonos_eventoHD.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
                 . "<input type='hidden' name='id_AB2' value='$id_abonosin' />"
                 . "<input type='hidden' name='rfck' value='$rfcin' />"
                 . "<input type='hidden' name='idAPk' value='$idAP' />"
                 . "<input type='submit' id='story_abonoD$rowi' value='Historial de pagos' />"
                 . "</form></td>"
                 . "<td id='regalosD$rowi'><form action='abonos_eventos_p3.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
                 . "<input type='hidden' name='monto' value='0' />"
                 . "<input type='hidden' name='restc' value='0' />"
                 . "<input type='hidden' name='fecha_i' value='$fechaLiq' />"
                 . "<input type='hidden' name='opc' value='0' />"
                 . "<input type='hidden' name='entrega' value='$dato[0]' />"
                 . "<input type='hidden' name='idABc' value='$id_abonosin' />"
                 . "<input type='hidden' name='idAPk' value='$idAP' />"
                 . "<input type='hidden' name='rfck' value='$rfcin' />"
                 . "</tr>"
              . "</tr>";
          $rowi++;} 
       if($tipohab==1) {
           echo "<tr>"
             . "<td>$rowi</td>"
              . "<td id=asigname><form action='abonos_eventos_p1.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
              . "<input type='text' id='asigtext$rowi' name='name' value='$Aname' />"
              . "<input type='hidden' name='row' value='$rowi' />"
              . "<input type='hidden' name='idABc' value='$id_abonosin' />"
              . "<input type='submit' id='asigboton$rowi' value='>' />"
              . "</form></td>"
              . "<td>$mq3->fecha_abono</td>"
              . "<td>$ $mq3->abono</td>"
              . "<td>$tipopagoT</td>"
              . "<td id='restante$rowi'>$ $mq3->restante</td>"
              . "<td>$liquidT</td>"
              . "<td>$fechaLiq</td>"
              . "<td><form name='agregar' action='abonos_evento2.php' method='post' target='xyz' onsubmit='abrir(\"xyz\");return false;'>"
              . "<input type='hidden' name='id_AB' value='$id_abonosin' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='submit' id='add_abono$rowi' value='Abonar a este cuarto' />"
              . "</form></td>"
              . "<td><form name='detalles' action='abonos_eventoH.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
              . "<input type='hidden' name='id_AB' value='$id_abonosin' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='submit' id='story_abono$rowi' value='Historial de pagos' />"
              . "</form></td>"
              . "<td id='regalos$rowi'><form action='abonos_eventos_p3.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"           
              . "<input type='hidden' name='monto' value='0' />"
              . "<input type='hidden' name='restc' value='0' />"
              . "<input type='hidden' name='fecha_i' value='$fechaLiq' />"
              . "<input type='hidden' name='opc' value='0' />"
              . "<input type='hidden' name='entrega' value='$dato[0]' />"
              . "<input type='hidden' name='idABc' value='$id_abonosin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "<input type='submit' id='entrega$rowi' value='Entregar Regalos' />"
              . "</form></td>"
              . "</tr>";
           $rowi++;
       }
 echo "</tbody></table>";
 
 }echo "<br><br><br>";
  }echo "</center>";
  }
  
  
   else{
        $mc1="select rfc from Apartado where rfc='$questrfc'";
        $mh1=mysql_query($mc1) or die("Error 0: ".mysql_error());
    if(mysql_affected_rows()){
        $rfcin=$questrfc;
        $rowi=0;
            $mc2="select * from Apartado where rfc='$rfcin'";
            $mh2=mysql_query($mc2)or die("Error 2: ".msql_error());
            while($mq2=mysql_fetch_object($mh2)){
                $idAP=$mq2->id_ap;
                $tipohab=$mq2->tipo_hab;
                $conce=$mq2->concepto;
                $fecha_aparta=$mq2->fecha_ap;
                if($tipohab==1){
                $tipohabT="Sencilla";
                $precio_hab=1500;
                }
                else{
                $tipohabT="Doble";
                $precio_hab=3500;
      }
   
   echo "<center><table border=5 cellspadding='2' bgcolor='#ffccff'><tbody><tr>"
     . "<th bgcolor='coffee'>RFC</th><th bgcolor='coffee'>Nombre</th><th bgcolor='coffee'>Concepto</th><th bgcolor='coffee'>Apartado N°</th><th bgcolor='coffee'>Tipo Habitación</th><th bgcolor='coffee'>Fecha de Apartado</th></tr>"
             . "<tr>"
             . "<td>$rfcin</td>"
             . "<td>Distribuidor sin Registro u.u</td>"
             . "<td>$conce</td>"
             . "<td>$idAP</td>"
             . "<td>Habitacion $tipohabT</td>"
             . "<td>$fecha_aparta</td>"
             . "</tr>"
             . "</tbody></table>"; 
   echo "<h2>Cuartos Reservados</h2>";
   $mc3="select * from abono_evento where id_ap=$idAP";
   $mh3=mysql_query($mc3) or die("Error 3: ".mysql_error());
while($mq3=mysql_fetch_object($mh3)){echo "<table border=3><tbody><tr>"
     . "<th bgcolor='coffee'>Cuarto N°</th><th bgcolor='coffee'>Asignar a</th><th bgcolor='coffee'>Ultimo Abono</th><th bgcolor='coffee'>Abono</th><th bgcolor='coffee'>Tipo de Pago</th><th bgcolor='coffee'>Restante</th><th bgcolor='coffee'>Liquidado</th><th bgcolor='coffee'>Fecha de Liquidado</th><th bgcolor='coffee'>Abonar</th><th bgcolor='coffee'>Historial</th></tr>";
  
    $id_abonosin=$mq3->id_abono;
      $liquid=$mq3->liquidado;
      if($liquid==1){
      $liquidT="SI";
      $fechaLiq=$mq3->fecha_liquid;
      }
      else{
      $liquidT="NO";
      $fechaLiq="---";
      }
      $liquid2=$mq3->liquidado2;
      if($liquid2==1){
      $liquidT2="SI";
      $fechaLiq2=$mq3->fecha_liquid2;
      }
      else{
      $liquidT2="NO";
      $fechaLiq2="---";
      }
      
      $Aname=$mq3->asignado_a;
      if($Aname==""){$Aname="---";}
      $Aname2=$mq3->asignado_a2;
      if($Aname2==""){$Aname2="---";}
      
      $tipopago=$mq3->tipo_pago;
      if($tipopago==0)$tipopagoT="Efectivo";
      if($tipopago==1)$tipopagoT="Depósito";
      if($tipopago==2)$tipopagoT="Tarjeta";
      if($tipopago==3)$tipopagoT="Voucher";
      if($tipopago==4)$tipopagoT="Regalías";
      if($tipopago==5)$tipopagoT="Por Pagar";
      $tipopago2=$mq3->tipo_pago2;
      if($tipopago2==0)$tipopagoT2="Efectivo";
      if($tipopago2==1)$tipopagoT2="Depósito";
      if($tipopago2==2)$tipopagoT2="Tarjeta";
      if($tipopago2==3)$tipopagoT2="Voucher";
      if($tipopago2==4)$tipopagoT2="Regalías";   
      if($tipopago2==5)$tipopagoT2="Por Pagar";
     
       $fr="select transacciones.idtransacciones from inversionista inner join transacciones on inversionista.id_inver = transacciones.inversionista_id_inver where transacciones.tipostr_idtipostr=38 and inversionista.id_inver='$id_inv'and transacciones.fechae='$fechaLiq'";
       $fgr=mysql_query($fr) or die ("error fr: la cagaste en la transaccion porque ".mysql_error());
       echo $fgr;
     if($tipohab==2){
         echo "<tr>"
             . "<td>$rowi</td>"
              . "<td id=asigname><form action='abonos_eventos_p1.php' target='xyz' onsubmit='abrir('xyz');return false;' method='post'>"
              . "<input type='text' id='asigtext$rowi' name='name' value='$Aname' />"
              . "<input type='hidden' name='row' value='$rowi' />"
              . "<input type='hidden' name='idABc' value='$id_abonosin' />"
              . "<input type='submit' id='asigboton$rowi' value='>' />"
              . "</form></td>"
              . "<td>$mq3->fecha_abono</td>"
              . "<td>$ $mq3->abono</td>"
              . "<td>$tipopagoT</td>"
              . "<td id='restante$rowi'>$ $mq3->restante</td>"
              . "<td>$liquidT</td>"
              . "<td>$fechaLiq</td>"
              . "<td><form name='agregar' action='abonos_evento2.php' method='post' target='xyz' onsubmit='abrir(\"xyz\");return false;'>"
              . "<input type='hidden' name='id_AB' value='$id_abonosin' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='submit' id='add_abono$rowi' value='Abonar a este cuarto' />"
              . "</form></td>"
              . "<td><form name='detalles' action='abonos_eventoH.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
              . "<input type='hidden' name='id_AB' value='$id_abonosin' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='submit' id='story_abono$rowi' value='Historial de pagos' />"
              . "</form></td>"
              . "<td id='regalos$rowi'><form action='abonos_eventos_p3.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
              . "<input type='hidden' name='monto' value='0' />"
              . "<input type='hidden' name='restc' value='0' />"
              . "<input type='hidden' name='fecha_i' value='$fechaLiq' />"
              . "<input type='hidden' name='opc' value='0' />"
              . "<input type='hidden' name='entrega' value='$dato[0]' />"
              . "<input type='hidden' name='idABc' value='$id_abonosin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='hidden' name='rfckc' value='$rfcin' />"
              . "<input type='hidden' name='noregis' value='25' />"
              . "<input type='submit' id='entrega$rowi' value='Entregar Regalos' />"
              . "</form></td>"
                 . "<tr><td></td>"
                 . "<td id=asigname><form action='abonos_eventos_p1D.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
                 . "<input type='text' id='asigtextD$rowi' name='name' value='$Aname2' />"
                 . "<input type='hidden' name='row' value='$rowi' />"
                 . "<input type='hidden' name='idABc' value='$id_abonosin' />"
                 . "<input type='submit' id='asigbotonD$rowi' value='>' />"
                 . "</form></td>"
                 . "<td>$mq3->fecha_abono2</td>"
                 . "<td>$ $mq3->abono2</td>"
                 . "<td>$tipopagoT2</td>"
                 . "<td id='restanteD$rowi'>$ $mq3->restante2</td>"
                 . "<td>$liquidT2</td>"
                 . "<td>$fechaLiq2</td>"
                 . "<td><form name='agregar' action='abonos_evento2D.php' method='post' target='xyz' onsubmit='abrir(\"xyz\");return false;'>"
                 . "<input type='hidden' name='id_AB2' value='$id_abonosin' />"
                 . "<input type='hidden' name='rfck' value='$rfcin' />"
                 . "<input type='hidden' name='idAPk' value='$idAP' />"
                 . "<input type='submit' id='add_abonoD$rowi' value='Abonar a este cuarto' />"
                 . "</form></td>"
                 . "<td><form name='detalles' action='abonos_eventoHD.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
                 . "<input type='hidden' name='id_AB2' value='$id_abonosin' />"
                 . "<input type='hidden' name='rfck' value='$rfcin' />"
                 . "<input type='hidden' name='idAPk' value='$idAP' />"
                 . "<input type='submit' id='story_abonoD$rowi' value='Historial de pagos' />"
                 . "</form></td>"
                 . "<td id='regalosD$rowi'><form action='abonos_eventos_p3.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
                 . "<input type='hidden' name='monto' value='0' />"
                 . "<input type='hidden' name='restc' value='0' />"
                 . "<input type='hidden' name='fecha_i' value='$fechaLiq' />"
                 . "<input type='hidden' name='opc' value='0' />"
                 . "<input type='hidden' name='entrega' value='$dato[0]' />"
                 . "<input type='hidden' name='idABc' value='$id_abonosin' />"
                 . "<input type='hidden' name='idAPk' value='$idAP' />"
                 . "<input type='hidden' name='rfckc' value='$rfcin' />"
                 . "<input type='hidden' name='noregis' value='25' />"
                 . "<input type='submit' id='entrega$rowi' value='Entregar Regalos' />"
                 . "</form></td>"
                 . "</tr>"
              . "</tr>";
          $rowi++;} 
       if($tipohab==1) {
           echo "<tr>"
             . "<td>$rowi</td>"
              . "<td id=asigname><form action='abonos_eventos_p1.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
              . "<input type='text' id='asigtext$rowi' name='name' value='$Aname' />"
              . "<input type='hidden' name='row' value='$rowi' />"
              . "<input type='hidden' name='idABc' value='$id_abonosin' />"
              . "<input type='submit' id='asigboton$rowi' value='>' />"
              . "</form></td>"
              . "<td>$mq3->fecha_abono</td>"
              . "<td>$ $mq3->abono</td>"
              . "<td>$tipopagoT</td>"
              . "<td id='restante$rowi'>$ $mq3->restante</td>"
              . "<td>$liquidT</td>"
              . "<td>$fechaLiq</td>"
              . "<td><form name='agregar' action='abonos_evento2.php' method='post' target='xyz' onsubmit='abrir(\"xyz\");return false;'>"
              . "<input type='hidden' name='id_AB' value='$id_abonosin' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='submit' id='add_abono$rowi' value='Abonar a este cuarto' />"
              . "</form></td>"
              . "<td><form name='detalles' action='abonos_eventoH.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"
              . "<input type='hidden' name='id_AB' value='$id_abonosin' />"
              . "<input type='hidden' name='rfck' value='$rfcin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='submit' id='story_abono$rowi' value='Historial de pagos' />"
              . "</form></td>"
              . "<td id='regalos$rowi'><form action='abonos_eventos_p3.php' target='xyz' onsubmit='abrir(\"xyz\");return false;' method='post'>"           
              . "<input type='hidden' name='monto' value='0' />"
              . "<input type='hidden' name='restc' value='0' />"
              . "<input type='hidden' name='fecha_i' value='$fechaLiq' />"
              . "<input type='hidden' name='opc' value='0' />"
              . "<input type='hidden' name='entrega' value='$dato[0]' />"
              . "<input type='hidden' name='idABc' value='$id_abonosin' />"
              . "<input type='hidden' name='idAPk' value='$idAP' />"
              . "<input type='hidden' name='rfckc' value='$rfcin' />"
              . "<input type='hidden' name='noregis' value='25' />"
              . "<input type='submit' id='entrega$rowi' value='Entregar Regalos' />"
              . "</form></td>"
              . "</tr>";
           $rowi++;
       }
 echo "</tbody></table>";
 
 }echo "<br><br><br>";
  }echo "</center>";
    }
    else{
    echo"RFC no Encontrado";}
   }
}
?>