    <!DOCTYPE html>
    <?php
    ob_start();
    $session_id = trim($_REQUEST['session_id']);
    session_save_path("../sesiones");
    session_name($session_id);
    session_start(); 
    $id_persona = $_SESSION['ID_PERSONA'];
      if(isset($id_persona)){
        include("../datos/mysqlpersona.php");                         
         $p = new mysqlpersona();
         $data = $p->getPersonaID($id_persona);
           for($i =0;$i<count($data);$i++){
                $nombre=  $data[$i]['NOMBRE'];
                $apellido_pa=  $data[$i]['APE_PATERNO'];
                $apellido_ma=  $data[$i]['APE_MATERNO'];
                $perfil =  $data[$i]['PERFIL'];
                $id_perfil=  $data[$i]['ID_PERFIL'];
                //DATA PERSONAL
                $email = $data[$i]['EMAIL'];
                $celular = $data[$i]['CELULAR'];
            }  
                $_SESSION['nombre']= $nombre;
                $_SESSION['ape_paterno']= $apellido_pa;
                $_SESSION['ape_materno']= $apellido_ma;
                $_SESSION['perfil']= $perfil;
                $_SESSION['id_perfil']= $id_perfil;
                //DATA PERSONAL
                $_SESSION['email']=$email;
                $_SESSION['celular']=$celular;
                $_SESSION['id_persona_registro'] = $_SESSION['ID_PERSONA'];
                $_SESSION['url'] = SID.'&session_id='.$session_id;
      }else{
         echo "<meta http-equiv='refresh' content='0;url=../administracion'>";
    }
?>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
        <title>Postventa</title>
        <link href="../css/style.default.css" rel="stylesheet">
        <link href="../css/select2.css" rel="stylesheet" />
        <link href="../css/bootstrap-dialog.min.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/tabletools/2.2.3/css/dataTables.tableTools.css">
        <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/plug-ins/9dcbecd42ad/integration/bootstrap/3/dataTables.bootstrap.css">
        <link rel="stylesheet" type="text/css" href="//editor.datatables.net/examples/resources/bootstrap/editor.bootstrap.css">
        <link href="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>
        <link href="../css/multi-select.css" media="screen" rel="stylesheet" type="text/css">
    </head>
    <body>
        <header>
            <div class="headerwrapper">
                <div class="header-left">  
                    <div class="pull-right">
                        <a href="#" class="menu-collapse">
                            <i class="fa fa-bars"></i>
                        </a>
                    </div>
                </div>
                <div class="header-right">
                    <div class="pull-right">                    
                        <div class="btn-group btn-group-option">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                              <i class="fa fa-caret-down"></i>
                            </button>
                            <ul class="dropdown-menu pull-right" role="menu">
                              <li><a id="configcuenta" href="#"><i class="glyphicon glyphicon-cog"></i> Configuración cuenta</a></li>
                              <li class="divider"></li>
                              <li><a id="cerrar_session" href="#"><i class="glyphicon glyphicon-log-out"></i>Cerrar sesión</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </header>
        <section>
            <div class="mainwrapper">
                <div class="leftpanel">
                     <div class="media profile-left">
                        <div class="media-body">
                            <h4 class="media-heading"><?php echo $_SESSION['perfil'];?></h4>
                            <small class="text-muted"><?php echo $_SESSION['nombre']." ".$_SESSION['ape_paterno']    ;?></small>
                        </div>
                    </div><!-- media -->
                    
                    <h5 class="leftpanel-title">Menu</h5>
                    <ul class="nav nav-pills nav-stacked">
                        <li class="active"><a href="dashboard?<?php echo SID.'&session_id='.$session_id?>"><i class="fa fa-home"></i> <span>Dashboard</span></a></li>
                          
                          <li class="parent"><a href="#"><i class="fa fa-inbox"></i> <span>Requerimientos</span></a>
                            <ul class="children">
                                 <li><a href="requerimientos?<?php echo SID.'&session_id='.$session_id?>">Lista</a></li>
                            </ul>
                        </li>
                          <li class="parent"><a href="#"><i class="fa fa-calendar"></i> <span>Calendario</span></a>
                            <ul class="children">
                                        <?php 
                                     if($_SESSION['id_perfil'] == "8"){
                                        ?>
                                       <li><a href="calendario?<?php echo SID.'&session_id='.$session_id?>">Calendario</a></li>


                                        <?php 
                                    }else{
                                            ?>                                       
                                        <li><a href="calendario?<?php echo SID.'&session_id='.$session_id?>">Calendario</a></li>
                                        <li><a href="configuracioncalendario?<?php echo SID.'&session_id='.$session_id?>">Configuración</a></li>
                                        <?php 
                                        }
                                    ?>
                            </ul>
                        </li>
                           <?php 
                            if($_SESSION['id_perfil'] == "8"){
                            }else{
                                ?>
                                    <li class="parent"><a href="#"><i class="fa fa-briefcase"></i> <span>Proyectos</span></a>
                                             <ul class="children">
                                                                                
                                <li><a href="proyectos?<?php echo SID.'&session_id='.$session_id?>">Lista Proyectos</a></li>
                                <li><a href="proyectomasivo?<?php echo SID.'&session_id='.$session_id?>">Crear Proyecto</a></li>
                                                <li ><a href="ambientes?<?php echo SID.'&session_id='.$session_id?>">Ambientes</a></li>
                                                <li><a href="tipopropiedad?<?php echo SID.'&session_id='.$session_id?>">Tipo Propiedad</a></li>
                                                <li><a href="modelospropiedades?<?php echo SID.'&session_id='.$session_id?>">Modelos Propiedades</a></li><li><a href="personas?<?php echo SID.'&session_id='.$session_id?>">Personas</a></li><li ><a href="propiedades?<?php echo SID.'&session_id='.$session_id?>">Propiedades</a></li>                            
                                            </ul>
                                        </li>
                                <?php 
                            }
                            ?>
                         <li class="parent"><a href="#"><i class="fa fa-pencil"></i> <span>Datos</span></a>
                            <ul class="children">
                                    <?php 
                                     if($_SESSION['id_perfil'] == "8"){
                                        ?>
                         
                                         <li><a href="servicios?<?php echo SID.'&session_id='.$session_id?>">Servicios</a></li>
                                         <li> <a href="configuracionCorreos?<?php echo SID.'&session_id='.$session_id?>">Configuración global Correo</a></li>

                                        <?php 
                                    }else{
                                        ?>
                                         <li><a href="usuarios?<?php echo SID.'&session_id='.$session_id?>">Usuarios</a></li>
                                         <li><a href="empresa?<?php echo SID.'&session_id='.$session_id?>">Empresa</a></li>

                                         <li><a href="categoria?<?php echo SID.'&session_id='.$session_id?>">Categoría</a></li>
                                         <li><a href="preguntas?<?php echo SID.'&session_id='.$session_id?>">Preguntas</a></li>
                                         <li><a href="responsable?<?php echo SID.'&session_id='.$session_id?>">Responsable</a></li>
                                         <li><a href="servicios?<?php echo SID.'&session_id='.$session_id?>">Servicios</a></li>
                                         <li> <a href="configuracionCorreos?<?php echo SID.'&session_id='.$session_id?>">Configuración global Correo</a></li>

                                        <?php 
                                        }
                                    ?>
                            </ul>
                        </li>
                        <?php 
                            if($_SESSION['id_perfil'] == "8"){
                            }else{
                                ?>
                                 <li class="parent "><a href="#"><i class="fa fa-suitcase"></i> <span>Terceros</span></a>
                                        <ul class="children">
                                             <li ><a href="procesoterceros?<?php echo SID.'&session_id='.$session_id?>">Generar Postventa</a></li>
                                        </ul>
                                    </li>
                                <?php 
                            }
                        ?>
                         <li class="parent"><a href="#"><i class="fa fa-copy"></i> <span>Reportes</span></a>
                            <ul class="children">
                                <li><a href="reportepostventa?<?php echo SID.'&session_id='.$session_id?>">Lista Reportes</a></li> 
                                <li><a href="ReporteTransparencia?<?php echo SID.'&session_id='.$session_id?>">Reporte Transparencia</a></li>                         
                            </ul>
                        </li>
                        <li class="parent"><a href="#"><span>Otras Páginas</span></a>
                            <ul class="children">
                                <li><a href="https://login.microsoftonline.com/">Microsoft Office 365</a></li>
                                <li><a href="http://vain-arm.cl/">Vain - Arm</a></li>
                                <li><a href="http://www.itodoslossantos.cl/web/">Inmobiliaria Todos los Santos</a></li>                           
                            </ul>
                        </li>
                    </ul>
                </div><!-- leftpanel -->


                <div class="mainpanel">
                    <div class="pageheader">
                        <div class="media">
                            <div class="pageicon pull-left">
                                <i class="fa fa-home"></i>
                            </div>
                            <div class="media-body">
                                <ul class="breadcrumb">
                                    <li><a href="#"><i class="glyphicon glyphicon-home"></i></a></li>
                                    <li>Dashboard</li>
                                </ul>
                                <h4>Dashboard</h4>
                            </div>
                        </div><!-- media -->
                    </div><!-- pageheader -->
                    
                    <div class="contentpanel">   
                         <div class="row">
                        <div class="col-sm-6">
                                <div class="panel panel-default">
                                    <div class="panel-heading">

                                        <div class="panel-btns" style="display: none;">
                                            <a href="" class="panel-minimize tooltips" data-toggle="tooltip" title="" data-original-title="Minimize Panel"><i class="fa fa-minus"></i></a>
                                        </div>
                                        <h5 class="md-title mt0 mb10">Utilidad:Buscar Contraseña</h5>
                                    </div>
                                    <div class="panel-body" style="display: block;">

                                         <div class="form-group">
                                            <label class="col-sm-4 control-label">Rut Propietario(*):</label>
                                            <div class="col-sm-8">
                                                       <div class="input-group custom-search-form">
                                                          <input  onchange="javascript:this.value=this.value.toUpperCase();Valida_Rut(this,'rut')" onkeypress="validacamposrut();" maxlength="10" required type="text" id="rut" name="rut" class="form-control">
                                                          <span class="input-group-btn">
                                                          <button  id="buscarrut" class="btn btn-default" type="button">
                                                          <span class="glyphicon glyphicon-search"></span>
                                                         </button>
                                                         </span>
                                                         </div>
                                            </div>
                                        </div>

                                        <div id="mostrar">
                                                <div  id="error" class="errorForm"></div>
                                                <div class="form-group">
                                                <label class="col-sm-4 control-label">Información:</label>
                                                    <div class="col-sm-8">
                                                            <ul class="list-unstyled social-list">
                                                                        <li><a>Nombre:</a><span id="nombre"></span></li>
                                                                        <li><a>Apellidos:</a><span id="apellidos"></span></li>
                                                                        <li><a>Celular:</a><span id="celular"></span></li>
                                                                        <li><a>Télefono Fijo:</a><span id="tel_fijo"></span></li>
                                                                        <li><a>Email:</a><span id="email"></span></li>
                                                                        <li><a>Pro-venta:</a><span id="procesoventa"></span></li>

                                                            </ul>
                                                    </div>
                                                </div>
                                        </div>







                                    </div>
                                </div>
                            </div>
                    </div>
    <!--                <div class="row">
                        <div class="col-sm-6">
                                <div class="panel panel-default">
                                    <div class="panel-heading">

                                        <div class="panel-btns" style="display: none;">
                                            <a href="" class="panel-minimize tooltips" data-toggle="tooltip" title="" data-original-title="Minimize Panel"><i class="fa fa-minus"></i></a>
                                        </div>
                                        <h5 class="md-title mt0 mb10">Postventa anuales por Proyecto</h5>
                                    </div>
                                    <div class="panel-body" style="display: block;">
                                        <div id="chart_div" style="height:600px;"></div>
                                    </div>
                                </div>
                            </div>
                        <div class="col-sm-5">
                                <div class="panel panel-default">
                                    <div class="panel-heading">

                                        <div class="panel-btns" style="display: none;">
                                            <a href="" class="panel-minimize tooltips" data-toggle="tooltip" title="" data-original-title="Minimize Panel"><i class="fa fa-minus"></i></a>
                                        </div>
                                        <h5 class="md-title mt0 mb10">Resumen Postventa</h5>
                                    </div>
                                    <div class="panel-body" style="display: block;">
                                         <div id="piechart_3d" style="width: 900px; height: 500px;"></div>
                                    </div>
                                </div>
                            </div>
                    </div>

 -->






















                     
                            </div>
                        </div><!-- row -->
                        
                    </div><!-- contentpanel -->
                    
                </div><!-- mainpanel -->
            </div><!-- mainwrapper -->
        </section>

  <div id="modalconfigcuenta" class="modal fade bs-example-modal-static" tabindex="-1" role="dialog" data-backdrop="static">
         <div class="modal-dialog modal-l">
              <div class="modal-content">
                  <div class="modal-header">
                      <button aria-hidden="true" data-dismiss="modal" class="close" type="button">&times;</button>
                      <h4 class="modal-title">Editar cuenta</h4>
                  </div>
                  <div class="modal-body">
                  <div class="row">
                              <div class="col-md-9">
                                            <div class="form-group">
                                                 <label class="col-sm-5 control-label">Perfil:</label>
                                                <div class="col-sm-7">
                                                    <a href="#"  data-type="text"    data-title="Ingresar Perfil"><?php echo $perfil; ?></a>                                               
                                                     </div>
                                            </div>
                                            <div class="form-group">
                                                 <label class="col-sm-5 control-label">Nombre:</label>
                                                <div class="col-sm-7">
                                                    <a href="#"   data-title="Ingresar Nombre"><?php echo $nombre." ".$apellido_pa." ".$apellido_ma; ?></a>                                               
                                                     </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-5 control-label">Celular:</label>
                                                <div class="col-sm-7">
                                                        <a href="#" id="configcelular" name="configcelular" data-type="text"  data-name="updatecelular" data-pk="<?php echo $_SESSION['ID_PERSONA'];?>"  data-title="Ingresar celular"><?php echo $celular; ?></a>                                                
                                                        </div>
                                            </div>
                                        
                                            <div class="form-group">
                                                <label class="col-sm-5 control-label">Correo Electrónico:</label>
                                                <div class="col-sm-7">
                                                        <a href="#"  id="configemail" name="configemail"  data-name="updateemail" data-type="text" data-pk="<?php echo $_SESSION['ID_PERSONA'];?>"  data-title="Ingrese Correo Electrónico "><?php echo $email; ?></a>                                                
                                                        </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-5 control-label">Contraseña:</label>
                                                <div class="col-sm-7">
                                                        <a href="#"  id="configpass" name="configpass"  data-name="restablecerpass" data-type="password" data-pk="<?php echo $_SESSION['ID_PERSONA'];?>"  data-title="Ingrese Contraseña">********</a>                                                
                                                  </div>
                                            </div>                       
                                </div>
                        </div>
                </div>
                    <div class="modal-footer">
                     <button  type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                     </div>
              </div>
            </div>
    </div>

        <script src="../js/jquery-1.11.1.min.js"></script>
        <script src="../js/jquery-migrate-1.2.1.min.js"></script>
        <script src="../js/jquery-ui-1.10.3.min.js"></script>
        <script src="../js/bootstrap.min.js"></script>
        <script src="../js/modernizr.min.js"></script>
        <script src="../js/pace.min.js"></script>
        <script src="../js/retina.min.js"></script>
        <script src="../js/jquery.cookies.js"></script>
        <script src="../js/bootstrap-wizard.min.js"></script>
        <script src="../js/jquery.validate.min.js"></script>
        <script src="../js/jquery.dataTables.min.js"></script>
        <script src="http://cdn.datatables.net/plug-ins/725b2a2115b/integration/bootstrap/3/dataTables.bootstrap.js"></script>
        <script src="http://cdn.datatables.net/responsive/1.0.1/js/dataTables.responsive.js"></script>
        <script src="../js/select2.min.js"></script>
        <script src="../js/custom.js"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
        <script src="../js/bootstrap-dialog.min.js"></script>
        <script src = "../js/funciones.js" type="text/javascript"></script>
        <script src="../js/jquery.multi-select.js"></script>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
        var id_sesion = "<?php echo $_SESSION['sesion'];?>" ;

      google.load("visualization", "1", {packages:["corechart"]});
        google.setOnLoadCallback(drawVisualization);

    function drawVisualization() {
      // Some raw data (not necessarily accurate)
      var data = google.visualization.arrayToDataTable([
        ['Meses', 
            'TODOS LOS SANTOS', 'CONDOMINIO SAN ISIDRO', 'CONDOMINIO SAN GIOVANNI', 'CONDOMINIO SAN LUIS', 'CONDOMINIO SANTA ROSA', 'CONDOMINIO SANTA TERESA','CONDOMINIO SAN PABLO ',
             'CONDOMINIO SAN IGNACIO','CONDOMINIO SANTA ESTER','CONDOMINIO SANTA BERNARDITA','CONDOMINIO SANTA TERESITA','CONDOMINIO SANTA SOFIA','CONDOMINIO SAN PEDRO','CONDOMINIO SAN ALFONSO',
             'CONDOMINIO SAN PEDRO'],
            ['2014',  0,938,522,998,450,614.6,450,450, 450, 450,450,450,450,450,450],
            ['2015',  0,938,522,998,450,614.6,450,450, 450, 450,450,450,450,450,450],

      ]);

      var options = {
       // title : 'Postventa anuales por Proyecto',
        hAxis: {title: "Meses"},
        seriesType: "bars",
        series: {5: {type: "line"}}
      };

          var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
          chart.draw(data, options);
    }


    google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['NUEVO',     30],
          ['PROCESO',     40],
          ['FINALIZADO',  10],
          ['POR CATEGORIZAR', 20]
        ]);

        var options = {
          is3D: true,
        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
        chart.draw(data, options);
      }
      
        $('#cerrar_session').click(function(){
             $.post( "../negocio/login.php", {indice:"cerrar_session",id_sesion:id_sesion})
               .done(function( data ){  
                    if(data == 1){
                      location.href="../administracion";
                    }             
              });
        });


         $('#configcuenta').click(function(){
            $('#modalconfigcuenta').modal({show:true});
        });

               $('#configpass').editable({
                    mode: 'inline',
                    rows: 6,
                    url:   "../negocio/usuarios.php",
                         validate: function(value) {
                        if($.trim(value) == '' ) {
                            return 'Esta campo es obligatorio';
                        }                   
                        },
                          success: function(data) {

                        },        
                });

                      $('#configcelular').editable({
                           type:  'text',
                           name:  'celular',
                           url:   "../negocio/usuarios.php",
                           tpl: "<input type='text' maxlength='12'>",
                           validate: function(value) {
                           if($.trim(value) == '' ) {
                                return 'Esta campo es obligatorio';
                            }
                            if ($.isNumeric(value) == '') {
                                return 'Solo números';
                            }
                        },
                           success: function(data) {
                            //alert(data);
                            },
   
                });

                   $('#configemail').editable({
                      type:  'text',
                       url:   "../negocio/usuarios.php",
                       tpl: "<input type='text' maxlength='30'>",
                       validate: function(value) {
                            if($.trim(value) == '' ) {
                                return 'Esta campo es obligatorio';
                            }
                            var v = validarEmail(value)         
                            if(v==false){
                                return 'Ingresa un Email válido';
                            }   
                        },
                          success: function(data) {
                              // alert(data);

                            },       
                });


        function validarEmail(email){
                expr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                if ( !expr.test(email) ){
                         return false;
                }else{
                        return true;
                     }
             }
            $('#buscarrut').click(function(){
                 $('#error').html(""); 
                var error_campos = "<label for='name' class='error'>No se encontró información relacionada</label>";
                var error_obligacion = "<label for='name' class='error'>Complete los campos obligatorios(*)</label>";

                var rut = $('#rut').val();
                if(rut == ""){
                     $('#error').html(error_obligacion); 
                    return false;
                }

                     $.post( "../negocio/usuarios.php", {name:"getUtilidadesBYRUT",rut:rut})
                       .done(function( data ){  
                          var datos = $.parseJSON(data);

                            if(datos == 0){
                                 $('#error').html(error_campos); 

                                        $('#nombre').text("");
                                        $('#apellidos').text("");
                                        $('#celular').text("");
                                        $('#tel_fijo').text("");
                                        $('#email').text("");
                                        $('#procesoventa').text("");

                                 return false;
                            }else{
                                     $(datos).each(function () { 
                                        $('#nombre').text(this.NOMBRE);
                                        $('#apellidos').text(this.APE_PATERNO+" "+this.APE_MATERNO);
                                        $('#celular').text(this.CELULAR);
                                        $('#tel_fijo').text(this.TEL_FIJO);
                                        $('#email').text(this.EMAIL);
                                        $('#procesoventa').text(this.PRO_VENTA);
                                    }); 

                            }

                      });

            });
      
    </script>
 
    </body>
</html>

