<!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'];
            $telefono_oficina = $data[$i]['TEL_OFICINA'];
            $telefono_fijo = $data[$i]['TEL_FIJO'];
        }  
            $_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=../login'>";
}
?>
<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 href="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>
<style>
.some_class{
   maxlength: 240px;
}
</style> 
    </head>
    <body>
            <form id="myform"  action='proceso' method='post'>
          <input type="hidden" name="id_cliente" value="<?php echo $_SESSION['ID_PERSONA'];?>"/>
        </form>



        <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="cerrar_session" href="../login"><i class="glyphicon glyphicon-log-out"></i>Cerrar sesión</a></li>
                            </ul>
                        </div><!-- btn-group -->
                        
                    </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 ><a href="proceso?<?php echo SID.'&session_id='.$session_id?>"><i class="fa fa-home"></i> <span>Atención de Postventa</span></a></li>
                        <li ><a href="pendientes?<?php echo SID.'&session_id='.$session_id?>"><i class="fa fa-calendar"></i> <span>Pendientes</span></a></li>
                        <li class="active"><a href="informacioncontacto?<?php echo SID.'&session_id='.$session_id?>"><i class="fa fa-edit"></i> <span>Información Contacto</span></a></li>
                        <li><a href="utilidades?<?php echo SID.'&session_id='.$session_id?>"><i class="fa  fa-file-text"></i> <span>Infórmate</span></a></li>
                    </ul>
                </div><!-- leftpanel -->
                <div class="mainpanel">
                    <div class="contentpanel">
                    <div class="col-md-1">
                    </div>
                    <div class="col-md-8">
                                <form id="form2" class="form-horizontal form-bordered">
                                    <div class="panel panel-default">
                                        <div class="panel-heading">
                                            <h4 class="panel-title">Información de Contacto</h4>
                                            <p>Es importante mantener la información de contacto actualizada para recibir notificaciones, información, etc.</p>
                                            <h5>Presione en el campo para editar la información</h5>
                                        </div>
                                        <div class="panel-body nopadding">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">Correo Electrónico:(*)</label>
                                                <div class="col-sm-8">
                                                        <a href="#"  id="email" name="email"  data-name="setEmail" data-type="text" data-pk="<?php echo $_SESSION['ID_PERSONA'];?>"  data-title="Ingrese Correo Electrónico "><?php echo $email; ?></a>                                                </div>
                                            </div><!-- form-group -->
                                                   <div class="form-group">
                                                <label class="col-sm-4 control-label">Celular:(*)</label>
                                                <div class="col-sm-8">
                                                        <a href="#" id="celular" name="celular" data-type="text"  data-name="setCelular" data-pk="<?php echo $_SESSION['ID_PERSONA'];?>"  data-title="Ingresar celular"><?php echo $celular; ?></a>                                                </div>
                                            </div><!-- form-group -->
                                        
                                               <div class="form-group">
                                                <label class="col-sm-4 control-label">Teléfono Fijo:</label>
                                                <div class="col-sm-8">
                                                        <a href="#" id="tel_fijo" name="tel_fijo" data-type="text" data-name="setTelfijo"  data-pk="<?php echo $_SESSION['ID_PERSONA'];?>"  data-title="Ingresar Teléfono fijo"><?php echo $telefono_fijo; ?></a>                                                </div>
                                            </div>
                                               <div class="form-group">
                                                <label class="col-sm-4 control-label">Teléfono Oficina:</label>
                                                <div class="col-sm-8">
                                                        <a href="#" id="tel_oficina" name="tel_oficina" data-type="text" data-name="setTelofi"  data-pk="<?php echo $_SESSION['ID_PERSONA'];?>" data-title="Ingresar Télefono oficina"><?php echo $telefono_oficina; ?></a>                                                </div>
                                            </div><!-- form-group -->
                                        </div><!-- panel-body -->
                      
                                    </div><!-- panel -->
                                </form>
                            </div>
                    </div>
                </div><!-- mainpanel -->
            </div><!-- mainwrapper -->
        </section>
        <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/select2.min.js"></script>
        <script src="../js/custom.js"></script>
        <script src = "../js/funciones.js" type="text/javascript"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
        <script type="text/javascript">
        jQuery(document).ready(function() {
            //$.fn.editable.defaults.mode = 'inline';
                    var id_sesion = "<?php echo $_SESSION['sesion'];?>" ;

            $('#email').editable({
                       type:  'text',
                       
                       url:   "../negocio/informacioncontacto.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) {
                            
                            },

                });

                 $('#celular').editable({
                           type:  'text',
                           name:  'celular',
                           url:   "../negocio/informacioncontacto.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) {
                            },
                });
     
               $('#tel_fijo').editable({
                           type:  'text',
                           name:  'tel_fijo',
                           url:   "../negocio/informacioncontacto.php",
                            tpl: "<input type='text' maxlength='12'>",

                             validate: function(value) {
                                if ($.isNumeric(value) == '') {
                                    return 'Solo números';
                                }
                            },
                           success: function(data) {

                            },

                });

                $('#tel_oficina').editable({
                           type:  'text',
                           name:  'tel_oficina',
                           url:   "../negocio/informacioncontacto.php",
                           tpl: "<input type='text' maxlength='12'>",
                            validate: function(value) {
                            if ($.isNumeric(value) == '') {
                                return 'Solo números';
                            }
                        },
                           success: function(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;
                     }
             }

            $('#cerrar_session').click(function(){
                 $.post( "../negocio/login.php", {indice:"cerrar_session",id_sesion:id_sesion})
                   .done(function( data ){  
                        if(data == 1){
                          location.href="../login";
                        }             
                  });
            });


            $('#irproceso').click(function(){
                 document.forms["myform"].submit();


            });




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