
<script>
 </script>

    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Editar Informe</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" id="FormActualizar">
              <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">ID Examen</label>
                <div class="col-sm-4">
                  <input type="text" class="form-control" id="id" name="id" placeholder="id" disabled>
                </div>
                <div class="col-sm-4">
		   <input type="datetime-local" class="form-control" id="fecha" name="fecha" placeholder="Fecha" disabled>
                </div>
              </div>
              <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">RUT</label>
                <div class="col-sm-4">
                  <input type="rut" class="form-control" id="rut" name="rut" placeholder="Rut" disabled>
                </div>
                <div class="col-sm-2">
                  <input type="dv" class="form-control" id="dv" name="dv" placeholder="Dv" disabled>
                </div>
              </div>
              <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">Nombres</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control col-sm-4" id="nombres" name="nombres" placeholder="Nombres" disabled>
                </div>
                <div class="col-sm-3">
		  <input type="text" class="form-control col-sm-4" id="ap_paterno" name="ap_paterno" placeholder="Ap. Paterno" disabled>
                </div>
                <div class="col-sm-3">
                  <input type="text" class="form-control col-sm-4" id="ap_materno" name="ap_materno" placeholder="Ap. Materno" disabled>
                </div>
              </div>
              <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">Informe</label>
	      </div>
              <div class="form-group">
               <div class="col-sm-1">
                <label for="inputEmail3" class="col-sm-2 control-label">&nbsp;</label>
	       </div>
	       <div class="col-sm-6">
		 <textarea name="informe" id="informe"></textarea>
	       </div>
               <div class="col-sm-1">
                <label for="inputEmail3" class="col-sm-2 control-label">&nbsp;</label>
	       </div>
	      </div>
	      <div class="form-group">
                <div class="col-sm-6">
                    <center>
                    <button type="button" id="btn_actualizar" class="btn btn-md btn-primary">Actualizar</button>
                    <button type="button" id="btn_borrar" class="btn btn-md btn-warning">Borrar</button>
                  </center>
                </div>                
                <div class="col-sm-6">
                    <center>
                  <button type="button" id="btn_cerrar" class="btn btn-md btn-default">Cerrar</button>
                  </center>
                </div>
              </div>                                                              
            </form>
      </div>            
        

<script>
$(document).ready(function(){
   <?php 
   $persona2 = json_decode($persona);
   $id =  $persona2[0]->{'id'};
   $fecha =  $persona2[0]->{'fecha'};
   $rut =  $persona2[0]->{'rut'};
   $dv =  $persona2[0]->{'dv'};
   $nombres =  $persona2[0]->{'nombres'};
   $ap_paterno =  $persona2[0]->{'ap_paterno'};
   $ap_materno =  $persona2[0]->{'ap_materno'};
   $informe =  $persona2[0]->{'informe'};
   $informe = str_replace("&Acirc;&nbsp;", "", $informe);
   ?> 
   //var datos =  <?php //echo $persona; ?>;
/*
   $('#id').val(datos[0].id);
   $('#fecha').val(datos[0].fecha);
   $('#rut').val(datos[0].rut);
   $('#dv').val(datos[0].dv);
   $('#nombres').val(datos[0].nombres);
   $('#ap_paterno').val(datos[0].ap_paterno);
   $('#ap_materno').val(datos[0].ap_materno);
*/
   $('#id').val('<?php echo $id; ?>');
   $('#fecha').val('<?php echo $fecha; ?>');
   $('#rut').val('<?php echo $rut; ?>');
   $('#dv').val('<?php echo $dv; ?>');
   $('#nombres').val('<?php echo $nombres; ?>');
   $('#ap_paterno').val('<?php echo $ap_paterno; ?>');
   $('#ap_materno').val('<?php echo $ap_materno; ?>');
   
   tinymce.init({
	 /*language: "es",*/
	 /*selector:'textarea',*/
	 mode: "textareas", 
	 /*skin: "xenmce",*/
	 statusbar: false,
	 width: 694,
	 height: 280,
	 entity_encoding : "raw",
	 plugins : "insertdatetime, fullpage, noneditable ",
		  /*   menubar: "tools table format edit view insert example",*/
	 menubar: " ",
	 toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image ",
	 noneditable_leave_contenteditable: true,
	 init_instance_callback : function(editor) {
	    editor.setContent('<?php echo htmlspecialchars_decode($informe); ?>');
	 }
      });

   $('#btn_actualizar').click(function() {
      tinyMCE.triggerSave();
      var parametros = {
		      "id" : $('#id').val(),
		      "informe" : $('#informe').val()
      };
      $.ajax({
	    data:  parametros,
	    url:   '<?php echo base_url();?>index.php/inicio/actualizar_informe',
	    type:  'post',
	    async:false,
	    success:  function (response) {
		  eval(response);
		  $('#ventana_modal').modal('hide'); 
		  $.ajax({
			data:  null,
			url:   '<?php echo base_url();?>index.php/inicio/tabla_informe',
			type:  'post',
			async:false,
			success:  function (response) {                
			      $('#contenido_tabla').html(response); 
			}
		 });   
	    }
      });                 
   });        
        
   $('#btn_cerrar').click(function() {
       $('#ventana_modal').modal('hide');
   });             


});

</script>