<?php
     include './ConexionII.php';
          include './GestionDB.php';
session_start();
$_SESSION['Contador']=0;
$_SESSION['Linea'] = array();
$_SESSION['Impresa'] = False;



if(isset($_SESSION['Usuario'])){
  
  

 
}else{

    //Si no le muestro otra página, puede ser la de Login
    header("Location: /MauricioCorrea/incorrecto.html");
}

$Fecha = date("y-m-d H:i:s");
$_SESSION['Fecha'] = strtotime('-5 hour', strtotime($Fecha));
$_SESSION['Fecha'] = date("y-m-d H:i:s", $_SESSION['Fecha']);


?>

<!DOCTYPE html>





<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>Pago</title>
                     <link rel="icon" type="image/png" href="imagenes/compra.png" />
        <script type="text/javascript" src="Js/jquery.min.js" ></script>
        <link rel="stylesheet" type="text/css" href="estilos.css">
        <link rel="stylesheet" type="text/css" href="fonts.css">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script src="menu.js"></script>
        
    </head>
    <body>
        
        <header>
<?php
if(isset($_SESSION['Usuario'])){

echo '<a class="datosusuario icon-exit" href="/MauricioCorrea/Cerrar.php"> - Salir</a>';
echo '<span class="datosusuario icon-users"> - Bienvenido '.$_SESSION['Nombre'].'</span>';


}else{
    header("Location: /MauricioCorrea/incorrecto.html");
}

 $Conexion = new Conexion();
    $DB = new GestionDBFacturas();
           
            $Con = $Conexion->conect();
            $DB->Numerofactura($Con);

            $query = 'SELECT * FROM clientes ORDER BY nombre';
            $result = mysql_query($query, $Con);

            





     echo '<div class="menu_bar">
        <a href="#" class="bt-menu"><span class="icon-newspaper"></span>Menu</a>
        </div>
            <nav>
                <ul>
                    <li><a href="inicio.php"><span class="icon-home"> </span>Inicio</a></li>  
                    <li class="submenu">
                    <a href="#"><span class="icon-user-tie"></span>Admin<span class="caret icon-circle-down"></span></a>    
                    <ul class="children">
                        <li><a href="Registro.php" ><span class="icon-user-plus"></span>Crea Vendedor</a></li>
                        <li><a href="ModificaVendedor.php" ><span class="icon-pencil"></span>Modifica Vendedor</a></li>
                        <li><a href="RegistroCliente.php" ><span class="icon-user-plus"></span>Crea Cliente <span class="user-plus"></a></li>
                        <li><a href="RegistroProveedor.php" ><span class="icon-user-plus"></span>Crea Proveedor <span class="user-plus"></a></li>
                       

                    </ul>
                    </li>


                    <li class="submenu">
                     <a href="#"><span class="icon-cart"> </span>Vend<span class="caret icon-circle-down"></span></a>
                      <ul class="children">
                        <li><a href="RegistroCliente.php" ><span class="icon-user-plus"></span>Crea Cliente <span class=""></a></li>
                        <li><a href="RegistroVenta.php" ><span class="icon-cart"></span>Crea Factura <span class=""></a></li>
                        <li><a href="RegistroRemision.php" ><span class="icon-file-text2"></span>Crea Remision <span class=""></a></li>
                        <li><a href="RegistroNota.php" ><span class="icon-files-empty"></span>Crea Nota <span class=""></a></li>
                    </ul>
                    </li>    





                     <li class="submenu">
                    <a href="#.php"><span class="icon-users"> </span>Clientes<span class="caret icon-circle-down"></span></a>    
                   <ul class="children">  
                    
                    <li><a href="RegistraCongelador.php"><span class="icon-credit-card"> </span>Registra Congelador</a></li>  
                    <li><a href="ModificaCliente.php"><span class="icon-user-check"> </span>Modificar Cliente</a></li>  
                    <li><a href="InformesClientes.php"><span class="icon-profile"> </span>Informe Clientes</a></li> 
                    <li><a href="InformesVentas.php"><span class="icon-calculator"> </span>Informe Ventas</a></li> 
                    </ul> 
                     </li>        

                       <li class="submenu">
                    <a href="#"><span class="icon-user-tie"></span>Proveedores<span class="caret icon-circle-down"></span></a>    
                    <ul class="children">
                    <li><a href="RegistroCompra.php" ><span class="icon-plus"></span>Carga Compra <span class="plus"></a></li>
                        <li><a href="ModificaProveedor.php" ><span class="icon-user-plus"></span>Modificar Proveedor</a></li>
                        
                        <li><a href="InformesCompras.php" ><span class="icon-stats-bars2"></span>Informe Compras <span class="plus"></a></li>

                    </ul>
                    </li>



                                        
                    <li class="submenu">
                    <a href="#.php"><span class="icon-droplet"> </span>Prod<span class="caret icon-circle-down"></span></a>    
                   <ul class="children">
                        <li><a href="CrearProducto.php" ><span class="icon-barcode"></span>Crea Producto <span class=""></a></li>
                        <li><a href="ModificarProducto.php" ><span class="icon-qrcode"></span>Modifica Producto <span class=""></a></li>
                        <li><a href="InformesInventarios.php" ><span class="icon-files-empty"></span>Informe Inventario <span class=""></a></li>
                    </ul> 
                     </li>    
                    <li><a href="Cerrar.php"><span class="icon-exit"> </span>Salir</a></li>                    
                </ul>
            </nav>
        </header>
        <section id="TablaLog1">
            
            <p>
            <form method="get" name="Registro" action="RegistroVenta.php">
            <div><p id="Titulo"> Nuevo pago </p></div>
            <br>
        
            
            <table  cellspacing="10"  style="margin: 0 auto;"  >
            <tr>
                <td>
                <span class="required"><div>Tipo</div></span>
                 <input type="text" id="tipo" disabled="disabled"  value="PAGO" name="tipo" autofocus="autofocus" required="required" class="required" style="width:140px; height:30px;">
              
                </td>
                <td>
                <span class="required"><div>Numero</div></span>
                <input type="text" disabled="disabled" name="numero" value=" '.$DB->Numeropago($Con); echo'" autofocus="autofocus" min="0" required="required" class="required" style="width:140px; height:30px;">
                </td>




                <td>
                <span class="required"><div>Fecha</div></span>
                <input type="text" id="dateDefault" disabled="disabled"  value="' .$_SESSION['Fecha']; echo'" name="fecha" autofocus="autofocus" required="required" class="required" style="width:130px; height:30px;">
                </td>

                 <td colspan="2">
                <span class="required"><div>Vendedor</div></span>
                 <input type="text" name="vendedor"  disabled="disabled" value="'. $_SESSION['Nombre'] . ' ' .$_SESSION['Apellido']; echo'" autofocus="autofocus" required="required" class="required" style="width:180px; height:30px;">
                </td>
             </tr>               
             <tr>
                    <td colspan="2">
                <span class="required"><div>Cliente</div></span>
                
';


$Fecha = date("y-m-d H:i:s");
$_SESSION['Fecha'] = strtotime('-5 hour', strtotime($Fecha));
$_SESSION['Fecha'] = date("y-m-d H:i:s", $_SESSION['Fecha']);

echo'


</form>

  <form method="post" name="Registro" action="RegistrarPago.php">
<select name="cliente" required="required" style="width:310px; height:30px;"/>';

$nombre = $_POST['cliente'];



while ($dato = mysql_fetch_array($result))
      
    {
        
    echo    '<option value="'.$dato['nombre']; echo'" >';
            echo $dato['nombre']; echo '</option>';
      
        
    }    
     
echo'
</select>
<td>
   <span class="required"><div><font size ="3", color ="#F1F1F1"> A </font></div></span>
        <input type="submit" name="GrabarCliente" Value="Grabar cliente" style="width:130px; height:40px; ">';
       

          if(isset($_POST['GrabarCliente'])){  
                
            $Conexion = new Conexion();
            $DB = new GestionDBCliente();
            $Con = $Conexion->conect();
            $query = 'SELECT * FROM clientes WHERE nombre = "'.$nombre.'"';
            $result = mysql_query($query, $Con);
            $dato = mysql_fetch_array($result);



            echo '
            </td>

<td colspan="2">
            <span class="required"><div>Dirección</div></span>
            <input type="text" disabled="disabled" name="direccion" value=" '.$dato['direccion']; echo'" autofocus="autofocus" min="0" required="required" class="required" style="width:180px; height:30px;">
            </td>

   <tr>
            

            <td>
            <span class="required"><div>Nombre</div></span>
            <input type="text" disabled="disabled" name="nombre" value=" '.$dato['nombre']; echo'" autofocus="autofocus" min="0" required="required" class="required" style="width:150px; height:30px;">
            </td>


            <td>
            <span class="required"><div>Cédula</div></span>
            <input type="text" disabled="disabled" name="cedula" value=" '.$dato['numerodocumento']; echo'" autofocus="autofocus" min="0" required="required" class="required" style="width:120px; height:30px;">
            </td>

 

         

            <td>
            <span class="required"><div>Teléfono</div></span>
            <input type="text" disabled="disabled" name="telefono" value=" '.$dato['telefono']; echo'" autofocus="autofocus" min="0" required="required" class="required" style="width:130px; height:30px;">
            </td>

            <td>
            <span class="required"><div>Celular</div></span>
            <input type="text" disabled="disabled" name="celular" value=" '.$dato['celular']; echo'" autofocus="autofocus" min="0" required="required" class="required" style="width:180px; height:30px;">
            </td>
            </tr>
            </form>
           <tr>
                <td colspan="2">
                <span class="required"><div>Facturas</div></span>
            <form method="get" name="RegistroPago" action="RegistrarPagoII.php">
            <select name="factura" required="required" style="width:310px; height:30px;"/>';
                    

$_SESSION['IdCliente'] = $dato['id'];
$_SESSION['NombreCliente'] = $dato['nombre'];
$_SESSION['ApellidoCliente'] = $dato['apellido'];
$_SESSION['Cedula'] =$dato['numerodocumento'];
$_SESSION['Ciudad'] =$dato['ciudad'];
$_SESSION['Direccion'] = $dato['direccion'];
$_SESSION['Ciudad'] = $dato['ciudad'];
$_SESSION['Telefono'] = $dato['telefono'];
$_SESSION['Celular'] = $dato['celular'];
//Cambio 1!!!



            $queryII = 'SELECT * FROM facturas WHERE cedulacliente = "'.$dato['numerodocumento'].'" AND estado LIKE "PENDIENTE" ORDER BY numero ASC';
            $resultII = mysql_query($queryII, $Con);
            
            if(mysql_num_rows($resultII) > 0 ){
            while ($datoII = mysql_fetch_array($resultII))
      
    {
        
    echo    '<option value="'.$datoII['numero']; echo'" >';
            echo $datoII['numero']; echo '</option>';
      
        
    } 
     echo '     
    </select>
    </td>
<td colspan="2">
                <span class="required"><div><font size ="3", color ="#F1F1F1"> A </font></div></span>
                

                <input type="submit" name="GrabarCongelador" Value="Grabar factura" style="width:310px; height:40px; " >
            </td>
    '; 



    echo '

            
                
        </form>
        
         
                        </p>
        </section>
'; 

    }else{
    
    
   
        
    echo    '<option value="" ></option>
      
   
      
    </select>
    </td>

                
        </form>
        
         
                        </p>
        </section>
'; 
    }      
    }  
   


            

            
          
          
          
       
        ?>
    </body>
</html>