<?php
session_start();
include_once("../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();

    }  
?>


<html>
<head>
<title>RRB - Abonos Eventos</title>
</head>

<body>
<script language='JavaScript' src='popcalendar.js'></script>
<?php 
echo"<script language=\"JavaScript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"></script>"
. "<script language='JavaScript' src='../scripts/validadorvoucher.js'></script>";
echo "<script language='JavaScript' src='../scripts/eventoani.js'></script>";
$idcdin = $sesion->id;
extract($_POST);
date_default_timezone_set("America/Mexico_City");
echo "<h1>Abonos</h1>";
        $mc1="select id_inver, nombre, appat, apmat from inversionista where rfc='$rfck'";
        $mh1=mysqli_query($conexion, $mc1) or die("Error 1".mysqli_error($conexion));
            if(mysqli_affected_rows($conexion))
            {   $mq1=  mysqli_fetch_object($mh1);
                $idinver=$mq1->id_inver;
                $nom=$mq1->nombre;
                $app=$mq1->appat;
                $apm=$mq1->apmat;
                echo "<center><h2>Bienvenido</h2>"
                    . "<label><b> $nom $app $apm RFC: $rfck</b></label>"
                    . "</center>";
                
                //ciclo de hbitaciones solicitadas
                $mc4="select restante from abono_evento where id_abono=$id_AB order by id_abono desc limit 1";
                $mh4=  mysqli_query($conexion, $mc4) or die ("Error 3 ".mysqli_error($conexion));
        
                while($mq4=  mysqli_fetch_object($mh4)){ $rest=$mq4->restante; echo "Le falta por pagar $rest"."<br>";}
               
                echo "<center>
                    <form name='pago' action='abonos_eventos_p3.php' method='post'>
                    Fecha del abono <input type='text' id='fecha_i' name='fecha_i' value='' /><input type='image' src='ew_calendar.gif' onClick=\"popUpCalendar(this,this.form.fecha_i,'yyyy-mm-dd');return false;\" />
                    Monto<input Type='text' name='monto' id='montino' onchange='verifvoucc()' />
                    Forma de pago<select name='opc' id='opc' onchange='tipopago2()'>
                    <option value='0'>Efectivo</option>
                    <option value='1'>Deposito</option>
                    <option value='2'>Tarjeta</option>
                    <option value='3'>Voucher</option>
                    </select>
                    <br>
                        <label>Voucher</label>
                        <input type='text' value='' placeholder='No.Voucher' id='vouch' name='vouchs' disabled>
                        <input type='button' id='validavo' value='Validar' onclick='validarvoueve();' disabled>
                        <label>Disponible $:</label><label id='mostrarvalor'></label>
                        <input type='hidden' id='valorvou' name='valorvouc'>
                        <br>
                        <label id='fichafo'>Folio de ficha de deposito:</label>
                        <input type='text' name='foliofic' id='foliofic' disabled>
                        <select id='banco' name='banco'>
                        <option value='1'>ScotiaBank</option>
                        <option value='3'>HSBC</option>
                        </select>
                        <br>
                        <input name='registrpedrfc' type='hidden' value='1'>
                        <br>
                    <font size=\"+2\">Centro de Entrega:</font></td><td><select name = \"entrega\">
			<option value=\"$idcdin\">$idcdin Mi Centro</option>
			<option value=\"8\">8 Almacen GDL</option>
			<option value=\"63\">63 Carlos Lopez Tuxtla</option>
                        <option value=\"64\">64 Lidia Cancun</option>
			<option value=\"80\">80 Esther Cancun</option>
			<option value=\"53\">53 Fausto Villahermosa</option>
			<option value=\"12\">12 Almacen General</option>			
			</select> 
                    <br>
                    <input type='hidden' name='idABc' value='$id_AB' />
                    <input type='hidden' name='idinvc' value='$idinver' />
                    <input type='hidden' name='restc' value='$rest' />
                    <input type='hidden' name='idAPc' value='$idAPk' />
                    <input type='submit' name='next2' value='Realizar Abono' id='confirm' />
                    </form>
                    </center> ";                         
   
    }//Sí se encontrpo RFC
   
            else{
    $mc1="select rfc from Apartado where rfc='$rfck'";
    $mh1=mysqli_query($conexion, $mc1) or die("Error 0: ".mysqli_error($conexion));
    if(mysqli_affected_rows($conexion)){
        echo "<center><h2>Bienvenido</h2>"
                    . "<label><b> Persona NO registrada u.u RFC: $rfck</b></label>"
                    . "</center>";
                
                //ciclo de hbitaciones solicitadas
                $mc4="select restante from abono_evento where id_abono=$id_AB order by id_abono desc limit 1";
                $mh4=  mysqli_query($conexion, $mc4) or die ("Error 3 ".mysqli_error($conexion));
        
                while($mq4=  mysqli_fetch_object($mh4)){ $rest=$mq4->restante; echo "Le falta por pagar $rest"."<br>";}
               
                echo "<center>
                    <form name='pago' action='abonos_eventos_p3.php' method='post'>
                    Fecha del abono <input type='text' id='fecha_i' name='fecha_i' value='' /><input type='image' src='ew_calendar.gif' onClick=\"popUpCalendar(this,this.form.fecha_i,'yyyy-mm-dd');return false;\" />
                    Monto<input Type='text' name='monto' id='montino' onchange='verifvoucc()' />
                    Forma de pago<select name='opc' id='opc' onchange='tipopago2()'>
                    <option value='0'>Efectivo</option>
                    <option value='1'>Deposito</option>
                    <option value='2'>Tarjeta</option>
                    </select>
                   
                        <br>
                        <label id='fichafo'>Folio de ficha de deposito:</label>
                        <input type='text' name='foliofic' id='foliofic' disabled>
                        <select id='banco' name='banco' disabled>
                        <option value='4'>ScotiaBank</option>
                        <option value='3'>HSBC</option>
                        </select>
                        <br>
                        <input name='registrpedrfc' type='hidden' value='1'>
                        <br>
                    <font size=\"+2\">Centro de Entrega:</font></td><td><select name = \"entrega\">
			<option value='$idcdin'>$idcdin Mi Centro</option>
			<option value='8'>8 Almacen GDL</option>
			<option value='63'>63 Carlos Lopez Tuxtla</option>
                        <option value='64'>64 Lidia Cancun</option>
			<option value='80'>80 Esther Cancun</option>
			<option value='53'>53 Fausto Villahermosa</option>
			<option value='12'>12 Almacen General</option>			
			</select> 
                    <br>
                    <input type='hidden' name='idABc' value='$id_AB' />
                    <input type='hidden' name='noregis' value='25' />
                    <input type='hidden' name='restc' value='$rest' />
                    <input type='hidden' name='rfckc' value='$rfck' />
                    <input type='hidden' name='idAPc' value='$idAPk' />
                    <input type='submit' name='next2' value='Realizar Abono' id='confirm' />
                    </form>
                    </center> ";                         
   
    }
    else {Echo "RFC no Encontrado";}//No se encontró RFC
            }
    //opcion RFC
 ?>
    </body>
</html>