<?php
session_start();
$id_session=$_SESSION['id_estrategia'];
include "./var.php";


$fechahoy = date("Y-m-d");

$clientesoption = getListaClientes();
$anoActual = date('Y');
$anoAnterior = $anoActual - 1;


$resulttabla = getcentrosdecostos();
$lnegociooption = getlnegociooption();
$proyectosnombres = getproyectosoption();
$formadedeingreso = getformaingreso();
$movingresosoption = getmovingresosoption();
$selectcuentasoption = getcuentas();
$proveedoresoption = getoptionproveedor();


$adicionales=<<<sss
<script src="../js/scripttable.js"></script>
<script>
var id_session = "$id_session";


</script>
sss;
    echo $varfirst;

    echo $var=<<<llll
        <div class="right_col" role="main">
            <div class="col-md-12 col-xs-12">
                <div class="x_panel">
                  
                    <div class="x_title">
                        <h2><strong>Egresos:</strong><small>Proyectado</small></h2>
                            
                        <ul class="nav navbar-right panel_toolbox">
                            <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                        </ul>
                        <div class="clearfix"></div>
                    </div>
                        
                    <div class="x_content">
                        
                        <ul class="nav nav-tabs nav-justified">
                            <li class="active nav"><a href="#Directos" data-toggle="tab"><h5><strong>Directos</strong></h5></a></li>
                            <li><a href="#Indirectos" data-toggle="tab" onclick="getIndirectos();"><h5><strong>Indirectos</strong></h5></a></li>
                        </ul>

                        <br><br>

                        <div class="tab-content">
                            <div class="tab-pane fade in active" id="Directos">
                                <form id="demo-form3" data-parsley-validate class="form-horizontal form-label-left">

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Cliente: </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <select class="form-control" id="listaCliente" required="required" onchange="getProyectosCliente();">
                                                <option value="">Seleccione cliente</option>
                                                $clientesoption
                                            </select>
                                        </div>
                                    </div>
                                
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Proyecto: </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <select class="form-control" id="listaProyectos" onchange="getCCProyecto();" disabled>
                                                <option value="">Seleccione proyecto</option>
                                            </select>
                                        </div>
                                    </div>
                            
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Centro de Costos: </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="textoCC" class="form-control col-md-7 col-xs-12" type="text" disabled>
                                        </div>
                                    </div>
                                </form>

                                <br/><br/><br/>

                                <ul class="nav nav-tabs nav-justified">
                                    <li class="active"><a href="#directoVariables" data-toggle="tab"><h5><strong>Directo Variable</strong></h5></a></li>
                                </ul>

                                <div class="tab-content">
                                    <div class="tab-pane fade in active" id="directoVariables">
                                        <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left">

                                            <div class="form-group">
                                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Tipo de proveedor: </label>
                                                <div class="col-md-6 col-sm-6 col-xs-12">
                                                    <select class="form-control" id="listaTiposProveedor" required="required" onchange="getInfoTipo();" disabled>
                                                        <option value="">Seleccione tipo de proveedor</option>
                                                        $proyectosnombres
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="control-label col-md-3 col-sm-3 col-xs-9" for="last-name">Presupuesto: $</label>
                                                <div class="col-md-6 col-sm-3 col-xs-3">
                                                    <input id="presupuestoE" class="form-control col-md-6 col-xs-11" type="text" onkeypress="return NumCheck(event, this)" name="subproy" required="required" disabled>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Fecha Inicial: </label>
                                                <div class="col-md-6 col-sm-6 col-xs-12">
                                                    <input id="fechainicialE" class="form-control col-md-7 col-xs-12" type="text" disabled>
                                                </div>
                                            </div>
                                    
                                            <div class="form-group">
                                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Fecha Final: </label>
                                                <div class="col-md-6 col-sm-6 col-xs-12">
                                                    <input id="fechafinalE" class="form-control col-md-7 col-xs-12" type="text" disabled>
                                                </div>
                                            </div>

                                            <br><br>
                                            
                                            <div class="form-group">
                                                <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-6 col-sm-offset-9 col-xs-offset-6">
                                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Ocupado: </label>
                                                    <div class="col-md-5 col-sm-5 col-xs-5">
                                                        <input id="inputPorcentajeE" class="form-control col-md-5 col-xs-5" type="text" onkeypress="return NumCheck(event, this)" name="subproy" required="required" disabled style='text-align:center;'>
                                                    </div>
                                                    <label class="control-label col-md-1 col-sm-1 col-xs-1" for="last-name">%</label>
                                                </div>
                                            </div>
                                                            
                                            <br>

                                            <div class="form-group">
                                                
                                                <div class="table-responsive" style="height: 210px; overflow: auto">
                                                    <table class="table table-striped jambo_table bulk_action" id="tablaEgresosPresupuestados" cellspacing="0">
                                                        <thead>
                                                            <th style='text-align:center;'>Año</th>
                                                            <th style='text-align:center;'>Mes</th>
                                                            <th style='text-align:center;'>Importe</th>
                                                            <th style='text-align:center;'>Porcentaje</th>
                                                        </thead>
                                                        <tbody>
                                                            $egresosdatos
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                            
                                            <div class="ln_solid"></div>
                                            <div class="form-group">
                                                <div class="col-md-4 col-sm-6 col-xs-3 col-md-offset-4">
                                                    <button type="button" id="botonAgregarEgreso" class="btn btn-success btn-block" onclick="guardarEgresos();" disabled>Guardar</button>
                                                </div>
                                            </div>

                                        </form>
                                    </div>
                                </div>

                                <br><br><br>

                                <ul class="nav nav-tabs nav-justified">
                                    <li class="active"><a href="#directoFijo" data-toggle="tab"><h5><strong>Directo Fijo</strong></h5></a></li>
                                </ul>

                                <div class="tab-pane fade in active" id="directoFijo">
                                    <div class="table-responsive" style="height: 210px; overflow: auto">
                                        <table class="table table-striped jambo_table bulk_action" id="tablaDirectoFijo" cellspacing="0">
                                            <thead>
                                                <th style='text-align:center;'>Año</th>
                                                <th style='text-align:center;'>Mes</th>
                                                <th style='text-align:center;'>Monto</th>
                                            </thead>
                                            <tbody>
                                                    
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                    

                            </div>



                            <div class="tab-pane fade" id="Indirectos">
                                    <br>
                                    <br>
                                                    
                                    <div class="table-responsive" style="height: 600px; overflow: auto">
                                        <table class="table table-striped jambo_table bulk_action" id="tablaIndPres" cellspacing="0">
                                            <thead>
                                                
                                                <tr>
                                                    <th style='text-align:center;'></th>
                                                    <th style='text-align:center;' colspan="2">$anoAnterior</th>
                                                    <th style='text-align:center;' colspan="2">$anoActual</th>
                                                </tr>
                                                <tr>
                                                    <th style='text-align:center;'>Mes</th>
                                                    <th style='text-align:center;'>Indirecto Variable</th>
                                                    <th style='text-align:center;'>Indirecto Fijo</th>
                                                    <th style='text-align:center;'>Indirecto Variable</th>
                                                    <th style='text-align:center;'>Indirecto Fijo</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                    
                                            </tbody>
                                        </table>
                                    </div>
                                                   
                                    <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left">
                                        
                                        <br><br>
                                                        
                                        <div class="form-group">
                                            <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-6 col-sm-offset-9 col-xs-offset-6">
                                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Factor I. Variable: </label>
                                                <div class="col-md-6 col-sm-6 col-xs-6">
                                                    <input id="inputIV" style='text-align:center;' class="form-control col-md-6 col-xs-12" type="number" required="required" disabled onchange='setIV();'>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group">
                                            <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-6 col-sm-offset-9 col-xs-offset-6">
                                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Factor I. Fijo: </label>
                                                <div class="col-md-6 col-sm-6 col-xs-6">
                                                    <input id="inputIF" style='text-align:center;' class="form-control col-md-6 col-xs-12" type="number" required="required" disabled onchange='setIF();'>
                                                </div>
                                            </div>
                                        </div>
                                                    
                                        <div class="form-group">
                                            <div class="col-md-2 col-sm-6 col-xs-3 col-xs-offset-8">
                                                <button type="button" id="botonGuardarIndirectos" class="btn btn-success btn-block" onclick="guardarIndirectos();" >Guardar</button>
                                            </div>
                                        </div>
                                                    
                                    </form>
                            
                            </div>

                        </div>



                    </div>
                </div>
            </div>
            <label></label>
        </div>

                                    
<script src="./js/moment.min.js"></script>
<script src="./js/egresosProyectados.js"></script>   

<script>
 
</script>
    

<script>
 </script>


                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
llll;
echo $varend;
echo $adicionales;
echo $cerrarend;

function getListaClientes(){
    $table = "clientes";
    $objeto = new db();
    $kuery = "SELECT * FROM `clientes`";
    $resultado = $objeto -> consultaregistros($kuery);
    $menu="";
    
    for($x = 0; $x < count($resultado); $x++){
        $id_clientes = $resultado[$x]["id_clientes"];
        $id_usuario = $resultado[$x]["id_usuario"];
        $Razon_social = $resultado[$x]["Razon_social"];
        $RFC = $resultado[$x]["RFC"];
        $contacto = $resultado[$x]["contacto"];
        $correo = $resultado[$x]["correo"];
        $telefono = $resultado[$x]["telefono"];
        $lnegocio = $resultado[$x]["lnegocio"];
        
        $menu.=<<<menu
            <option value = "$id_clientes"> $Razon_social </option>
menu;
    }
return $menu;
}


?>