<?php
session_start();
require_once('conexion.php');
require_once('include/sesiones.php');
if (isset($_SESSION['usu_nombre']))
{
    $regis=mysqli_query($con,"SELECT * from permiso where modulo_mod_id='1' and usuario_usu_id='$usu_id'  ") or die(mysqli_error($con));
    $reg=mysqli_fetch_array($regis);
        if($reg['per_visualizar']=="Activo")
        {
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<?php include ('head.php'); ?>
</head>
<body>
<?php
$inicio="";
$M_inventario="";
$M_contactos="";
$M_compras="";
$M_ventas="";
$M_pedidos="";
$M_pos="";
$R_reportes="";

$m_empresa="active";
$m_sucursales="";
$m_mesas="";
$m_configuraciones="";
$m_online="";
include ('menu.php');
?>   
<div class="main">
     <div class="col-md-2">
        <?php include ('include/menu_inicio.php'); ?> 
    </div> <!-- /span6 -->
    <div class="col-md-10"> 	
        <div class="widget stacked ">
            <div class="widget-content">
                <div class="widget stacked ">
                    <div class="widget-content">
                        <div class="row-fluid user-row" >
                            <div class="col-sm-1 col-xs-2">
                                <i class="fas fa-industry fa-4x"></i>
                            </div>
                            <div class="col-sm-10 col-xs-9">
                            </br>
                                <h4><strong>INFORMACIÓN DE LA EMPRESA</strong></h4>
                                <span class="text-muted"></span>
                            </div>
                            <div class="col-sm-1 col-xs-1 dropdown-user" data-for=".empresa" align="center">
                                <i class="icon-chevron-down text-muted"></i>
                            </div>
                        </div>
                        <div class="row-fluid user-infos empresa">
                            <div class="offset1">
                                <?php include ('php_empresas/form_datos_empresa.php');?>               
                            </div>
                        </div>
                    </div>
                </div>
                <div class="widget stacked ">
                    <div class="widget-content">
                        <div class="row-fluid user-row">
                            <div class="col-sm-1 col-xs-2">
                                <i class="fas fa-hashtag fa-4x"></i>
                             </div>
                            <div class="col-sm-10 col-xs-9">
                            </br>
                                <h4><strong>NUMERACIÓN DE DOCUMENTOS</strong></h4>
                                <span class="text-muted"></span>
                            </div>
                            <div class="col-sm-1 col-xs-1 dropdown-user" data-for=".serie" align="center">
                                <i class="icon-chevron-down text-muted"></i>
                            </div>
                        </div>
                        <div class="row-fluid user-infos serie">
                            <div class="offset1">
                                <div class="col-md-2" style="padding-left: 0px;">
                                    <button data-toggle="modal" data-target="#mod_serie" class="btn btn-info">NUEVA NUMERACION </button>
                                </div>
                                <div class="col-md-3">
                                    <select class="form-control" onchange='loadTabla(1);' id="q">
                                        <?php if($facturador=='si') { ?>
                                        <option value="0"> - - </option>
                                        <option value="1">Factura de Venta Electronica</option>
                                        <option value="4">Nota Crédito</option>
                                        <option value="5">Nota Debito</option>
                                        <option value="15">Documento Equivalente P.O.S</option>
                                        <option value="26">Nota Crédito al Documento Equivalente P.O.S</option>
                                        <option value="25">Nota Debito al Documento Equivalente P.O.S</option>
                                        <option value="remision">Remision</option>
                                        <option value="9">Nomina Individual</option>
                                        <option value="10">Nomina Individual de Ajuste</option>
                                        <option value="11">Documento de Soporte Electronico</option>
                                       
                                        <?php } else { ?>
                                        <option value="remision">Remision</option>

                                        <?php } ?>
                                    </select> 
                                </div>
                                <div class="col-md-8"></br></div>
                                <div class="resultados_tabla"></div>    
                                <div id="tabla"></div>              
                            </div>
                        </div>
                    </div>
                </div>

                <div class="widget stacked ">
                    <div class="widget-content">
                        <div class="row-fluid user-row">
                            <div class="col-sm-1 col-xs-2">
                                <i class="fas fa-money-bill-alt fa-4x"></i>
                            </div>
                            <div class="col-sm-10 col-xs-9">
                                </br>
                                <h4> <strong>BANCOS</strong></h4>
                                <span class="text-muted"></span>
                            </div>
                            <div class="col-sm-1 col-xs-1 dropdown-user" data-for=".banco" align="center">
                                <i class="icon-chevron-down text-muted"></i>
                            </div>
                        </div>
                        <div class="row-fluid user-infos banco">
                            <div class="col-md-6"> 
                                <form method="post" name="form_ban" id="form_ban">
                                    <div id="resultados_ban"></div>
                                    <div class="form-group">                      
                                    <input type="text" class="form-control" name="banco_nombre" id="banco_nombre" required placeholder="Nombre" >
                                    </div> <!-- /control-group -->
                                    <br>
                                    <div class="form-group pull-right">
                                        <button id="registrar_ban" type="submit" class="btn btn-success">Registrar </button> 
                                    </div> <!-- /form-actions -->
                                </form>  
                            </div>
                            <br>
                            <div class="col-md-6"> 
                                <center><span id="loader"></span></center>
                                <div id="bancos"></div>
                            </div>                 
                        </div>
                    </div>
                </div>
            </div> <!-- /widget-content -->
        </div> <!-- /widget -->
        </br></br>
	</div> <!-- /span6 -->
</div> <!-- /main -->
       
<?php
    require_once('php_empresas/form_nueva_serie.php'); 
	include ('php_caja/caja_abrir.php');
	include ('script.php');
?>
<script src="php_empresas\ajax.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    loadTabla(1);
});

function loadTabla(page)
{
    var q= $("#q").val();
    $.ajax({
        url:'./php_empresas/tabla_series.php?action=ajax&page='+page+'&q='+q,
        beforeSend: function(objeto){
        $('#tabla').html('<img src="./img/ajax-loader.gif"> Cargando...');
        },
        success:function(data){
        $(".resultados_tabla").html(data).fadeIn('slow');
         $('#tabla').html('');
        }
    })
}

function loadbancos(){
    $.get("./php_empresas/tabla_banco.php","",function(data){
    $("#bancos").html(data);
    })
}
loadbancos();


$("#form_formato").submit(function( event ) {
$('#mod_formato').attr("disabled", true);
var parametros = $(this).serialize();
   $.ajax({
      type: "POST",
      url: "php_configuraciones/editar_formato.php",
      data: parametros,
        beforeSend: function(objeto){
        $('#resultados_for').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
        },
        success: function(datos){
        $("#resultados_for").html(datos);
        $('#mod_formato').attr("disabled", false);
        }
    });
    event.preventDefault();
})

$("#form_ban").submit(function( event ) {
$('#registrar_ban').attr("disabled", true);
var parametros = $(this).serialize();
    $.ajax({
      type: "POST",
      url: "php_empresas/registrar_banco.php",
      data: parametros,
        beforeSend: function(objeto){
         $('#resultados_ban').html('<center><img src="./img/ajax-loader.gif"> CARGANDO...</center>');
        },
        success: function(datos){
        $("#resultados_ban").html(datos);
        $('#registrar_ban').attr("disabled", false);
        document.getElementById("form_ban").reset();
        loadbancos();
        }
    });
    event.preventDefault();
})

</script>
<style type="text/css">
.user-row {
    margin-bottom: 10px;
}
.user-row:last-child {
    margin-bottom: 0;
}
.dropdown-user {
    margin: 13px 0;
    padding: 5px;
    height: 100%;
}
.dropdown-user:hover {
    cursor: pointer;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
    var panels = $('.user-infos');
    var panelsButton = $('.dropdown-user');
    panels.hide();

    panelsButton.click(function() {
        var dataFor = $(this).attr('data-for');
        var idFor = $(dataFor);

        var currentButton = $(this);
        idFor.slideToggle(400, function() {
            if(idFor.is(':visible'))
            {
                currentButton.html('<i class="icon-chevron-up text-muted"></i>');
            }
            else
            {
                currentButton.html('<i class="icon-chevron-down text-muted"></i>');
            }
        })
    });
    $('[data-toggle="tooltip"]').tooltip();
});
</script>

</body>
</html>
<?php
}
else
{
   echo '<script>alert("No tienes permiso para ver esta pagina")</script>';
   echo '<script> setTimeout("history.back(1)", 0); </script>';
}
}
else
{
    echo '<script>location.href = "index.php";</script>';
}
?>