<?php use_helper('UrlFunctions');

//http://tinymce.moxiecode.com/examples/office.php
if($control){//cuando se hizo el submit
  
   
  if(is_array($tipo)){
    
    $o_TesisBean = new TesisBean();
    $o_TesisBean->setTesisId($id);
    $o_TesisBean->setTipoTesisId($cboTipoTesis);
    $o_TesisBean->setCodigoBAN($txtCodigoBAN);
    $o_TesisBean->setDescripcion($txtTitulo);
    $o_TesisBean->setTituloObtener($txtTituloObtener);
    $o_TesisBean->setPalabraClave($txtClave);
    $o_TesisBean->setFilePdf($_FILES);
    $o_TesisBean->setFechaAprobacion($FechaAprobacion);
    $o_TesisBean->setFechaPublicacion($FechaPublicacion);
    $o_TesisBean->setFechaSustentacion($FechaSustentacion);
    $o_TesisBean->setFacultadId($cboFacultad);
    $o_TesisBean->setEspecialidadId($cboEspecialidad);
    
    $o_TesisBean->setUsuarioModificacion(myUser::getUser()->getUserId());
    $o_TesisBean->setFechaModificacion(date('Y-m-d H:i:s'));
    
    while(list($key,$val_tipo)=each($tipo)){
      switch ($val_tipo){
        case "alm":
                 
                $o_TesisAlumnoBean = new TesisAlumnoBean();
                $o_TesisAlumnoBean->setTesisId($id);
                
                $o_AlumnoBean = new AlumnoBean();
                $o_AlumnoBean->setCodigoAlumno($codigo[$key]);
                $o_AlumnoBL = new AlumnoBL();
                $a_ObjectAlumnoBean = $o_AlumnoBL->busquedaAlumno($o_AlumnoBean);
                
                $o_TesisAlumnoBean->setAlumnosId($a_ObjectAlumnoBean[0]->getAlumnosId());
                $o_TesisAlumnoBean->setParticipacion($part[$key]);
                $o_TesisAlumnoBean->setFechaRegistro(date("Y-m-d H:i:s"));
                $o_TesisAlumnoBean->setUsuarioRegistro(myUser::getUser()->getUserId());
                
                if($li[$key] && $a_ObjectAlumnoBean[0]->getAlumnosId() == $li[$key]){
                               
                  $o_TesisAlumnoBean->setFechaModificacion(date("Y-m-d"));
                             
                  $a_concatResultAUpd[] = $o_TesisAlumnoBean;
                }else{
                  $o_TesisAlumnoBean->setUsuarioRegistro(myUser::getUser()->getUserId());
                  $o_TesisAlumnoBean->setFechaRegistro(date("Y-m-d"));
            
                  $a_concatResultA[] = $o_TesisAlumnoBean;
                }
                
                break;
              
        case "doc":
                
                $o_TesisDocenteBean = new TesisDocenteBean();
                $o_TesisDocenteBean->setTesisId($id);
                 
                $o_DocenteBean = new DocenteBean();
                $o_DocenteBean->setCodigoDocente($codigo[$key]);
                $o_DocenteBL = new DocenteBL();
                $a_ObjectDocenteBean = $o_DocenteBL->busquedaDocente($o_DocenteBean);
                
                $o_TesisDocenteBean->setDocenteId($a_ObjectDocenteBean[0]->getDocenteId());
                $o_TesisDocenteBean->setParticipacion($part[$key]);
                $o_TesisDocenteBean->setFechaRegistro(date("Y-m-d H:i:s"));
                $o_TesisDocenteBean->setUsuarioRegistro(myUser::getUser()->getUserId());
                
                if($li[$key] && $o_TesisDocenteBean->getDocenteId() == $li[$key]){
                  $o_TesisDocenteBean->setFechaModificacion(date("Y-m-d"));
                  $o_TesisDocenteBean->setUsuarioModificacion(myUser::getUser()->getUserId());
                  
                  $a_concatResultDUpd[] = $o_TesisDocenteBean;
                }else{
                  $o_TesisDocenteBean->setUsuarioRegistro(myUser::getUser()->getUserId());
                  $o_TesisDocenteBean->setFechaRegistro(date("Y-m-d"));
            
                  $a_concatResultD[] = $o_TesisDocenteBean;
                }
                
                break;
          
        case "ext":
          
                $o_TesisExternoBean = new TesisExternoBean();
                $o_TesisExternoBean->setTesisId($id);
                 
                $o_ExternoBean = new ExternoBean();
                $o_ExternoBean->setCodigo($codigo[$key]);
                $o_ExternoBL = new ExternoBL();
                $a_ObjectExternoBean = $o_ExternoBL->busquedaExterno($o_ExternoBean);
                
                $o_TesisExternoBean->setExternoId($a_ObjectExternoBean[0]->getExternoId());
                $o_TesisExternoBean->setParticipacion($part[$key]);
                $o_TesisExternoBean->setFechaRegistro(date("Y-m-d H:i:s"));
                $o_TesisExternoBean->setUsuarioRegistro(myUser::getUser()->getUserId());
                             
                
                if($li[$key] && $o_TesisExternoBean->getExternoId() == $li[$key]){
                  $o_TesisExternoBean->setFechaModificacion(date("Y-m-d"));
                  $o_TesisExternoBean->setUsuarioModificacion(myUser::getUser()->getUserId());
                 
                  $a_concatResultEUpd[] = $o_TesisExternoBean;
                }else{
                  $o_TesisExternoBean->setUsuarioRegistro(myUser::getUser()->getUserId());
                  $o_TesisExternoBean->setFechaRegistro(date("Y-m-d"));
            
                  $a_concatResultE[] = $o_TesisExternoBean;
                }
                break;
          
      }
    }
    
    $o_TesisBean->setArrayTesisAlumnoAct($a_concatResultAUpd);
    $o_TesisBean->setArrayTesisDocenteAct($a_concatResultDUpd);
    $o_TesisBean->setArrayTesisExternoAct($a_concatResultEUpd);
    
    $o_TesisBean->setArrayTesisAlumno($a_concatResultA);
    $o_TesisBean->setArrayTesisDocente($a_concatResultD);
    $o_TesisBean->setArrayTesisExterno($a_concatResultE);
    
    $o_TesisSystemClass = new TesisSystemClass($o_TesisBean);
    $bResult = $o_TesisSystemClass->modificarTesis();
    
   


    if($bResult){
    ?>
      <script language="JavaScript">
      parent.objMainTab.reqBody('<?=buildUrl('te/'.$typeSubmit)?>','&block=001&update=1&cod=<?=$o_TesisBean->getTesisId()?>');
      </script>
    <?
    }
    exit;   
  }
  
  
}

if($id){
  $o_TesisBean = new TesisBean();
  $o_TesisBean->setTesisId($id);
  
  
  $o_TesisBL = new TesisBL();
  $o_TesisBean = $o_TesisBL->busquedaTesisDetalles($o_TesisBean);
  
  $a_TesisDocente = $o_TesisBean->getArrayTesisDocente();
  $a_TesisAlumno  = $o_TesisBean->getArrayTesisAlumno();
  $a_TesisExterno = $o_TesisBean->getArrayTesisExterno();
} 


$o_TesisSystemClass = new TesisSystemClass(new TipoTesisBean());
$a_TipoTesis = $o_TesisSystemClass->getTipoTesis();


//Facultades
$o_DocenteSystemClass = new DocenteSystemClass(new FacultadBean());
$a_Facultad = $o_DocenteSystemClass->getFacultad();

?>

<script>
validateControls = function(){
  var errOutput               = { error:false, msg:"" };
  
  var valueTipo               = $('cboTipoTesis'); 
  //var valueTitulo             = $('txtTitulo');
    
  //var valueFechaPublicacion   = $('FechaPublicacion');
  //var valueFin      = $('txtFecFin');
  
 /* if(valueTitulo.value == ""){
    errOutput.error = true;
    errOutput.msg   += "Debe de digitar el titulo.\n";
  }*/
  if(valueTipo.value == ""){
    errOutput.error = true;
    errOutput.msg   += "Debe de seleccionar el tipo.\n";
  }
//   
//  var valueTitulo             = $('txtTitulo');
//  var valueClave              = $('txtClave');
//  //var valueTipo             = $('cboTipo');
//  var valueFechaPublicacion   = $('FechaPublicacion');
//  //var valueFin      = $('txtFecFin');
//  
//  if(valueTitulo.value == ""){
//    errOutput.error = true;
//    errOutput.msg   += "Debe de digitar el titulo.\n";
//  }
//  if(valueClave.value == ""){
//    errOutput.error = true;
//    errOutput.msg   += "Debe de digitar la clave.\n";
//  }
  /*if(valueTipo.value == ""){
    errOutput.error = true;
    errOutput.msg   += "Debe de seleccionar el tipo.\n";
  }*/
//  if(valueFechaPublicacion.value == ""){
//    errOutput.error = true;
//    errOutput.msg   += "Debe de ingresar la fecha de publicacion.\n";
//  }
  /*if(valueFin.value == ""){
    errOutput.error = true;
    errOutput.msg   += "Debe de ingresar la fecha de recepcion.\n";
  }*/
  
  return errOutput;
}
</script>

<script type="text/javascript" src="<?php echo Constantes::ROOT_DIR_APP?>/web/js/objectForm.js"></script>

<script type="text/javascript">
  validatePass = function(){
    valid.onSubmit = false;
  }
</script>
<!--
<script>
validateControls = function(){
  var errOutput         = { error:false, msg:"" };

  return errOutput;
}
</script>-->

<script>
actualizarElementos = function(elmValue, elmDestino,type){
  var url = '<?=buildUrl('ajax/request')?>';
  var pars = 'type=name&typeFind='+type+'&nombreElm='+elmDestino+'&value='+elmValue;
  
	var myAjax = new Ajax.Request(
                            		url, 
                            		{
                            			method: 'get', 
                            			parameters: pars, 
                            			onComplete: actualizaJSON
                            		});
}
</script>
<script>
actualizaJSON = function(request, json){
  var numeroElementos = json.length;
  for (var i = 0; i < numeroElementos; i++){
    if($(json[i][0])){
  	  switch ($(json[i][0]).tagName){
  	    case 'TD'      : Element.update(json[i][0], json[i][1]); break;
  	    case 'INPUT'   : $(json[i][0]).value=json[i][1]; break;
  	    case 'SELECT'  : 
  	      var objDDL = $(json[i][0]);
  	      if(typeof(cont) == 'undefined'){
  	        var cont = 0;
  	        objDDL.options.length = 1;
  	      }
  	      var a_contentValues = json[i][1].split("_;_");
      		var value	= a_contentValues[0];
      		var text	= a_contentValues[1];
  	      var option	= new Option(text,value);
      		try{
      			objDDL.add(option,null);
      		}catch (e){
      			objDDL.add(option,-1);
      		}
  	      cont++;
  	    break;
  	  }
    }else{
      if(json[i][0].indexOf("function") > -1){
        eval("scriptEval = "+json[i][0]);
        scriptEval();
      }
    }
  }
}
</script>


<script>
insertOptionDefault = function(){
  
  var table = $('tableContent');
  var countRows = table.rows.length;
  
  var tr = table.rows[countRows-1];
  var td = tr.cells[1];
  var idSelect = td.firstChild.id;
  
  //values = [[idSelect,'doc_;_Docente'],[idSelect,'alm_;_Alumno'],[idSelect,'ext_;_Externo']];
  values = [[idSelect,'alm_;_Alumno']];
  
  actualizaJSON('', values);
  
}
</script>

<script>
events = function(type){
  oReturn = validateControls();
  if(!oReturn.error){
    switch (type){
      case 'submit':
        if(grid.getCountRows() > 1){
          if(grid.validateRows()){
            disabledWin.show(true,true,'idGrid')
            $('form1').submit();
          }else{
            alert("Verifique el formulario.");
          }
        }else{
          elementLoad.show(undefined,'&nbsp;&nbsp;&nbsp;Tiene que Ingresar detalles.'); setTimeout('elementLoad.hide()',3000);
        }
      break;
      case 'insert':
        grid.insert();
        insertOptionDefault();
      break;
      case 'delete':
        grid.deletes();
      break;
    }
  }else{
    alert(oReturn.msg);
    return false;
  }
}
</script>

<script>
buscaDetalle = function(e,elm){
  var charCode;
  if (navigator.appName == "Mozilla" || navigator.appName == "Netscape"){
    charCode = e.keyCode;
  }else{
    charCode = event.keyCode;
  }
  if (charCode == 114){
    
    var parentTr      = elm.parentNode.parentNode.id;
    var valueSelect   = $(parentTr + "_td_1_tipo[]").value;
    var url           = "";
    
    if(valueSelect != ""){
      switch (valueSelect){
        case 'doc':
          url = '<?=buildUrlComplet('mnt.php/doc/listFind')?>iframe/contentResultxx/nameElm/'+elm.id+'/value/'+elm.value;
          tit = 'Docente';
        break;
        case 'alm':
          url = '<?=buildUrlComplet('mnt.php/alm/listFind')?>iframe/contentResultxx/nameElm/'+elm.id+'/value/'+elm.value;
          tit = 'Alumno';
        break;
        case 'ext':
          url = '<?=buildUrlComplet('mnt.php/ext/listFind')?>iframe/contentResultxx/nameElm/'+elm.id+'/value/'+elm.value;
          tit = 'Externo';
        break;
      }
      parent.objMainTab.modalDialog(url,{title:'Busqueda de '+ tit,width:600,height:420});
    }else{
      elementLoad.show(undefined,'&nbsp;&nbsp;&nbsp;Seleccione el tipo para el ListFind.'); setTimeout('elementLoad.hide()', 1000);
    }
  }
}
</script>

<script>
acutalizarEspecialidad = function(destino,elm){
  $(destino).options.length = 1;
  var url = '<?=buildUrlComplet('mnt.php/ajax/request')?>';
  var pars = 'type=getEspecialidad&nombreElm='+destino+'&value='+elm.value;
  
	var myAjax = new Ajax.Request(
                            		url, 
                            		{
                            			method: 'get', 
                            			parameters: pars, 
                            			onComplete: actualizaJSON
                            		});
}

actionSelect = function(elm){
  
  var parentTr      = elm.parentNode.parentNode.id;
  
  $(parentTr + "_td_2_codigo[]").value = "";
  $(parentTr + "_td_3").innerHTML = "&nbsp;";
  $(parentTr + "_td_4_part[]").value = "";
  
}

actionCod = function(elm){

  elm       = $(elm);
  elm.value = elm.value.trim();
  var elmValue = elm.value;
  
  parentTr = elm.parentNode.parentNode.id;
  
  elmDestino = parentTr + "_td_3";
  
  if(elmValue != ""){
    
    if(!grid.validateByColumn(2, elm, 'INPUT')){
    
      var parentTr      = elm.parentNode.parentNode.id;
      var valueSelect   = $(parentTr + "_td_1_tipo[]").value;
      
      $(elmDestino).innerHTML = "&nbsp;";
      formItem.loadProcess(parentTr + "_td_3");
      actualizarElementos(elmValue, elmDestino, valueSelect);
      
    }else{
      
      elm.value = "";
      elementLoad.show(undefined,'&nbsp;&nbsp;&nbsp;El Código ya fue Ingresado'); setTimeout('elementLoad.hide()', 1000);
      $(elmDestino).innerHTML = "&nbsp;";
      
    }
    
  }
  
}

</script>
<script type="text/javascript">
tinyMCE.init({

mode : "textareas",

theme : "advanced",

elements : "txtTitulo",

theme_advanced_toolbar_align : "left",

theme_advanced_toolbar_location : "top"



});

</script>
<img src="/images/common/spacer.gif" width="10">
<table class="cuerpo" width="98%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="0">
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td class="titleBody">
            <li>Tesis</li>
            <span class="subtitle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:::&nbsp;Ficha de Tesis (Edici&oacute;n)</span></td>
          <td align="right" valign="baseline">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td valign="top">
      <form id="form1" name="form1" method="POST" onsubmit="validatePass();" enctype="multipart/form-data">
      <input type="hidden" name="control" value="1">
      <fieldset>
			<legend>Datos Generales</legend>
			
      <table   width="100%"  class="marco">
        <tr>
          <td valign="top">
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="50%"  valign="top"><table  border="0" cellpadding="0" cellspacing="2" class="SubCabecera">
                    <tr>
                      <td width="24%" nowrap="nowrap"><label class="label req" for="txtCod"><span class="label Req">C&oacute;digo BAN </span>:</label>                      </td>
                     <td nowrap="nowrap"><input class="text" type="text" name="txtCodigoBAN" id="txtCodigoBAN" maxlength="10" value="<?php echo $o_TesisBean->getCodigoBAN()?>"/></td>
                    </tr> 
                    <tr>
                      <td width="24%" nowrap="nowrap"><label class="label req" for="txtCod"><span class="label Req">Tipo </span>:</label>                      </td>
                      <td width="76%" nowrap="nowrap"> <select class="combo  validate-selection" name="cboTipoTesis" id="cboTipoTesis" >
    					                 <option value="" > - Seleccionar - </option>
                                <?php foreach ($a_TipoTesis as $iKey => $o_TipoTesisBean){?>
                               		 <option value="<?=$o_TipoTesisBean->getTipoTesisId()?>"   <? if(is_object($o_TesisBean->getObjectTipoTesis()) && $o_TesisBean->getObjectTipoTesis()->getTipoTesisId() == $o_TipoTesisBean->getTipoTesisId()){echo "selected";}?>>
                                	<?=$o_TipoTesisBean->getTipoTesisDescripcion()?>
                                </option>
                                <?php  
                                }?> 
                           </select>
                       </td>
                    </tr>
                    <tr>
                      <td width="24%" nowrap="nowrap"><label class="label req" for="txtCod"><span class="label Req">T&iacute;tulo </span>:</label>                      </td>
                      <td width="76%" nowrap="nowrap"><textarea id="txtTitulo" name="txtTitulo" cols="65" rows="6"><?php echo $o_TesisBean->getDescripcion()?></textarea><!--<input id="txtTitulo" name="txtTitulo" size="60" type="text" class="text"/>--></td></td>
                    </tr>
                     <tr>
                      <td nowrap="nowrap"><label class="label Req" for="txtCod">Fecha Sustentaci&oacute;n :</label></td>
                      <td nowrap="nowrap"><input class="text" ondblclick="this.value=''" type="text"  readonly name="FechaSustentacion" id="FechaSustentacion"  size="8" value="<?php echo $o_TesisBean->getFechaSustentacion()?>"/><button type="button" onclick="return false" id="btnFechaSustentacion">...</button>
                      <script type="text/javascript">
                            document.getElementById("btnFechaSustentacion").disabled = false;
                            Calendar.setup({
                              inputField : "FechaSustentacion",
                              ifFormat : "%Y-%m-%d",
                              daFormat : "%Y-%m-%d",
                              button   : "btnFechaSustentacion"
                            });
                        </script></td>
                    </tr>
                   
                    
                </table></td>
                <td width="50%" valign="top"><table class="SubCabecera" width="100%" border="0" cellpadding="0" cellspacing="2">
                    <tr>
                      <td height="24" nowrap="nowrap"><label class="label Req" for="txtCod">Subir PDF  :</label></td>
                      <td nowrap="nowrap"><input class="button" type="file" name="file_pdf" id="file_pdf" />
                      <?php
                        $filename = Constantes::PATH_FILE_PDF.'tes_'.$id.'.pdf';
                        //echo $filename;
                        if (file_exists($filename)) {?>
                            <a href="/images/pdf/tes_<?php echo $id?>.pdf" class="label" target="_blank">view Pdf</label></a>
                        <?
                        } else {
                            echo "<label class='label'>No hay Resumen en PDF.....!</label>";
                        }
                        ?>
                      </td>
                    </tr>
                    <tr>
                      <td nowrap="nowrap"><label class="label Req" for="txtCod">Grado/Titulo Obtener :</label></td>
                      <td nowrap="nowrap"><input name="txtTituloObtener" id="txtTituloObtener" size="60" type="text" class="text" value="<?=$o_TesisBean->getTituloObtener()?>"/></td>
                    </tr>
                    <tr>
                      <td nowrap="nowrap"><label class="label Req" for="txtCod">Clave :</label></td>
                      <td nowrap="nowrap"><input name="txtClave" id="txtClave" size="60" type="text" class="text" value="<?=$o_TesisBean->getPalabraClave()?>"/></td>
                    </tr>
                     <tr>
                      <td height="26" nowrap="nowrap"><label class="label Req" for="txtCod">Fecha Aprobaci&oacute;n :</label></td>
                      <td nowrap="nowrap"><input class="text" ondblclick="this.value=''" type="text" readonly name="FechaAprobacion" id="FechaAprobacion" size="8"  value="<?php echo $o_TesisBean->getFechaAprobacion()?>"/><button type="button" onclick="return false" id="btnFechaAprobacion">...</button>
                      <script type="text/javascript">
                            document.getElementById("btnFechaAprobacion").disabled = false;
                            Calendar.setup({
                              inputField : "FechaAprobacion",
                              ifFormat : "%Y-%m-%d",
                              daFormat : "%Y-%m-%d",
                              button   : "btnFechaAprobacion"
                            });
                        </script>
                      </td>
                    </tr>
                     <tr>
                      <td nowrap="nowrap"><label class="label Req" for="txtCod">Fecha Publicac&oacute;n :</label></td>
                      <td nowrap="nowrap"><input class="text" ondblclick="this.value=''" type="text"  readonly  name="FechaPublicacion" id="FechaPublicacion"  size="8" value="<?php echo $o_TesisBean->getFechaPublicacion()?>"/><button type="button" onclick="return false" id="btnFechaPublicacion">...</button>
                      <script type="text/javascript">
                            document.getElementById("btnFechaPublicacion").disabled = false;
                            Calendar.setup({
                              inputField : "FechaPublicacion",
                              ifFormat : "%Y-%m-%d",
                              daFormat : "%Y-%m-%d",
                              button   : "btnFechaPublicacion"
                            });
                        </script></td>
                    </tr>
                     <tr>
                      <td nowrap="nowrap"><label class="label" for="txtCod">Facultad</label></td>
                      <td colspan="4" nowrap="nowrap">
                          
                          <select name="cboFacultad" id="cboFacultad" type="text" class="combo" onchange="acutalizarEspecialidad('cboEspecialidad',this)"/> 
                          <option value="" > - Seleccionar - </option>
                            <?php foreach ($a_Facultad as $iKey => $o_FacultadBean){ ?>
                              <option value="<?=$o_FacultadBean->getFacultadId()?>" <?php if($o_FacultadBean->getFacultadId() == $o_TesisBean->getFacultadId()) echo " selected "?>>
                                <?=$o_FacultadBean->getDescripcion()?>
                              </option>
                              <?php } ?>
                        </td>
                    </tr>
                     <tr>
                      <td nowrap="nowrap"><label class="label" for="txtCod">Especialidad/Carrera</label></td>
                      <td colspan="4" nowrap="nowrap"><input name="cboEspecialidad" id="cboEspecialidad" type="text" class="combo" value="<?=$o_TesisBean->getEspecialidadId()?>"/></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            <br>
            </form>
            
                  <table width="100%" height="200" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td valign="top" id="contentDetail">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td>
                              <table border="0" cellspacing="0" cellpadding="0" width="100%">
                                <tr>
                                  <td class="tabSpace">&nbsp;</td>
                                  <td class="ssTab ssTabAct" id="ttab1" onclick=";" nowrap="nowrap">Detalle</td>
                                  <td class="tabSpace">&nbsp;</td>
                                  <td width="100%" class="tabSpace">&nbsp;</td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                          <tr>
                            <td class="marcoTab">
                              <div id="tab1">
                                <table class="SubDetalle" width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td valign="top">
                                      <table width="100%" border="0" cellpadding="5" cellspacing="0">
                                        <tr>
                                          <td height="0">&nbsp;</td>
                                        </tr>
                                        <tr>
                                          <td align="left">
                                            <table class="marco" border="0" cellpadding="0" cellspacing="0" width="100%">
                                              <tr>
                                                <td>
                                                  <table class="grid" id="tableContent" width="100%" border="0" cellpadding="0" cellspacing="0">
                                                    <tbody id="idGrid">
                                                      <tr height="23">
                                                        <th width="5%" nowrap="nowrap">Nro</th>
                                                        <th width="15%" nowrap="nowrap">Tipo</th>
                                                        <th width="15%" nowrap="nowrap">Código</th>
                                                        <th width="55%" nowrap="nowrap" align="left">Nombre</th>
                                                        <th width="10%" nowrap="nowrap"></th>
                                                      </tr>
                                                     <?
                                                      $i = 0;
                                                      foreach ($a_TesisDocente as $iKey => $o_TesisDocente){ 
                                                       $i++; ?>
                                                      <tr 
                                                         id="idGrid_tr_<?=$i?>" 
                                                         onmouseout  ="JavaScript:formItem.loadEngine('grid','leaveHover','idGrid_tr_<?=$i?>')" 
                                                         onmouseover ="JavaScript:formItem.loadEngine('grid','enterHover','idGrid_tr_<?=$i?>')" 
                                                         ondblclick  ="JavaScript:formItem.loadEngine('grid','rowSelect','idGrid_tr_<?=$i?>')" style="background-color: rgb(255, 255, 255);"
                                                      >
                                                        <td id="idGrid_tr_<?=$i?>_td_0" align="center" code="count"><?=$i?></td>
                                                         <td id="idGrid_tr_<?=$i?>_td_1" align="center" code="tipo[]">
                                                                  <select 
                                                                  onclick   = "" 
                                                                  onkeyup   = "" 
                                                                  
                                                                  id        = "idGrid_tr_<?=$i?>_td_1_tipo[]" 
                                                                  name      = "tipo[]" 
                                                                  code      = "tipo[]"
                                                                  >
                                                                  
                                                                  <option value="doc" selected >Docente</option>
                                                                  
                                                                  </select>
                                                                
                                                        </td>
                                                        <td id="idGrid_tr_<?=$i?>_td_2" align="center" code="codigo[]"><input 
                                                                  type      = "text" 
                                                                  onclick   = "" 
                                                                  onkeyup   = "" 
                                                                  style     = "text-align: center;" 
                                                                  onkeydown = "buscaDetalle(event,this);" 
                                                                  onfocus   = "this.select();" 
                                                                  onblur    = "actionCod(this);" 
                                                                  class     = "text mayus" 
                                                                  size      = "8" 
                                                                  id        = "idGrid_tr_<?=$i?>_td_2_codigo[]" 
                                                                  name      = "codigo[]" 
                                                                  code      = "codigo[]"
                                                                  value     = "<?=$o_TesisDocente->getObjectDocente()->getCodigoDocente()?>"/>
                                                        </td>
                                                        <td align="left" id="idGrid_tr_<?=$i?>_td_3"><?=$o_TesisDocente->getObjectDocente()->getNombre()?></td>
                                                        <td align="center" id="idGrid_tr_<?=$i?>_td_4" code="part[]"><input
                                                                  type      = "text" 
                                                                  onblur    = "actionAxo(this);" 
                                                                  onclick   = "this.select();" 
                                                                  style     = "text-align: center;" 
                                                                  class     = "text" 
                                                                  size      = "4" 
                                                                  id        = "idGrid_tr_<?=$i?>_td_4_part[]" 
                                                                  name      = "part[]" 
                                                                  code      = "part[]"
                                                                  value     = "<?=$o_TesisDocente->getParticipacion()?>"/>
                                                        </td>
                                                        <td><input style="text-align:center;visibility:hidden" type="hidden" name="li[]" value="<?=$o_TesisDocente->getObjectDocente()->getDocenteId()?>"></td>
                                                       </tr>
                                                      <? }
                                                      foreach ($a_TesisAlumno as $iKey => $o_TesisAlumno){ 
                                                        $i++ ?>
                                                      <tr 
                                                         id="idGrid_tr_<?=$i?>" 
                                                         onmouseout  ="JavaScript:formItem.loadEngine('grid','leaveHover','idGrid_tr_<?=$i?>')" 
                                                         onmouseover ="JavaScript:formItem.loadEngine('grid','enterHover','idGrid_tr_<?=$i?>')" 
                                                         ondblclick  ="JavaScript:formItem.loadEngine('grid','rowSelect','idGrid_tr_<?=$i?>')" style="background-color: rgb(255, 255, 255);"
                                                      >
                                                        <td id="idGrid_tr_<?=$i?>_td_0" align="center" code="count"><?=$i?></td>
                                                         <td id="idGrid_tr_<?=$i?>_td_1" align="center" code="tipo[]"><select 
                                                                  onclick   = "" 
                                                                  onkeyup   = "" 
                                                                 
                                                                  onChange:"actionSelect(this);"
                                                                  id        = "idGrid_tr_<?=$i?>_td_1_tipo[]" 
                                                                  name      = "tipo[]" 
                                                                  code      = "tipo[]"
                                                                  >
                                                                  
                                                                  <option value="alm"  selected >Alumno</option>
                                                                  
                                                                  </select>
                                                                
                                                        </td>
                                                        <td id="idGrid_tr_<?=$i?>_td_2" align="center" code="codigo[]"><input 
                                                                  type      = "text" 
                                                                  onclick   = "" 
                                                                  onkeyup   = "" 
                                                                   style     = "text-align: center;" 
                                                                  onkeydown = "buscaDetalle(event,this);" 
                                                                  onfocus   = "this.select();" 
                                                                  onblur    = "actionCod(this);" 
                                                                  class     = "text mayus" 
                                                                  size      = "8" 
                                                                  id        = "idGrid_tr_<?=$i?>_td_2_codigo[]" 
                                                                  name      = "codigo[]" 
                                                                  code      = "codigo[]"
                                                                  value     = "<?=$o_TesisAlumno->getObjectAlumno()->getCodigoAlumno()?>"/>
                                                        </td>
                                                        <td align="left" id="idGrid_tr_<?=$i?>_td_3"><?=$o_TesisAlumno->getObjectAlumno()->getNombre()?></td>
                                                        <td align="center" id="idGrid_tr_<?=$i?>_td_4" code="part[]"><input
                                                                  type      = "text" 
                                                                  onblur    = "actionAxo(this);" 
                                                                  onclick   = "this.select();" 
                                                                  style     ="text-align:center;visibility:hidden"
                                                                  class     = "text" 
                                                                  size      = "4" 
                                                                  id        = "idGrid_tr_<?=$i?>_td_4_part[]" 
                                                                  name      = "part[]" 
                                                                  code      = "part[]"
                                                                  value     = "<?=$o_TesisAlumno->getParticipacion()?>"/>
                                                        </td>
                                                        <td><input  type="hidden" name="li[]" value="<?=$o_TesisAlumno->getObjectAlumno()->getAlumnosId()?>"></td>
                                                      </tr>
                                                      <? }
                                                      foreach ($a_TesisExterno as $iKey => $o_TesisExterno){ 
                                                        $i++ ?>
                                                      <tr 
                                                         id="idGrid_tr_<?=$i?>" 
                                                         onmouseout  ="JavaScript:formItem.loadEngine('grid','leaveHover','idGrid_tr_<?=$i?>')" 
                                                         onmouseover ="JavaScript:formItem.loadEngine('grid','enterHover','idGrid_tr_<?=$i?>')" 
                                                         ondblclick  ="JavaScript:formItem.loadEngine('grid','rowSelect','idGrid_tr_<?=$i?>')" style="background-color: rgb(255, 255, 255);"
                                                      >
                                                        <td id="idGrid_tr_<?=$i?>_td_0" align="center" code="count"><?=$i?></td>
                                                         <td id="idGrid_tr_<?=$i?>_td_1" align="center" code="tipo[]"><select 
                                                                  onclick   = "" 
                                                                  onkeyup   = "" 
                                                                 
                                                                  onChange:"actionSelect(this);"
                                                                  id        = "idGrid_tr_<?=$i?>_td_1_tipo[]" 
                                                                  name      = "tipo[]" 
                                                                  code      = "tipo[]"
                                                                  >
                                                                  <option value="ext" selected>Externo</option>
                                                                  </select>
                                                                
                                                        </td>
                                                        <td id="idGrid_tr_<?=$i?>_td_2" align="center" code="codigo[]"><input 
                                                                  type      = "text" 
                                                                  onclick   = "" 
                                                                  onkeyup   = "" 
                                                                  style     = "text-align: center;" 
                                                                  onkeydown = "buscaDetalle(event,this);" 
                                                                  onfocus   = "this.select();" 
                                                                  onblur    = "actionCod(this);" 
                                                                  class     = "text mayus" 
                                                                  size      = "8" 
                                                                  id        = "idGrid_tr_<?=$i?>_td_2_codigo[]" 
                                                                  name      = "codigo[]" 
                                                                  code      = "codigo[]"
                                                                  value     = "<?=$o_TesisExterno->getObjectExterno()->getCodigo()?>"/>
                                                        </td>
                                                        <td align="left" id="idGrid_tr_<?=$i?>_td_3"><?=$o_TesisExterno->getObjectExterno()->getNombre()?></td>
                                                        <td align="center" id="idGrid_tr_<?=$i?>_td_4" code="part[]"><input
                                                                  type      = "text" 
                                                                  onblur    = "actionAxo(this);" 
                                                                  onclick   = "this.select();" 
                                                                  style     = "text-align:center;"
                                                                  class     = "text" 
                                                                  size      = "4" 
                                                                  id        = "idGrid_tr_<?=$i?>_td_4_part[]" 
                                                                  name      = "part[]" 
                                                                  code      = "part[]"
                                                                  value     = "<?=$o_TesisExterno->getParticipacion()?>"/>
                                                        </td>
                                                        <td><input style="text-align:center;visibility:hidden" type="hidden" name="li[]" value="<?=$o_TesisExterno->getObjectExterno()->getExternoId()?>"></td>
                                                      <? } ?>
                                                        
                                                    </tbody>
                                                  </table>
                                                </td>
                                              </tr>
                                            </table>
                                            <input class="button" name="bten" type="button" value="Agregar Participante" onclick="/*grid.insert();*/ events('insert');" />
                                            <input class="button" name="bten3" type="button" value="Borrar" onclick="/*grid.deletes();*/ events('delete');"/>
                                          </td>
                                        </tr>
                                      </table>
                                    </td>
                                  </tr>
                                </table>
                              </div>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                  <div align="right">
                  <input type="hidden" name="typeSubmit" id="typeSubmit" onkeyup="">
                  <input class="button" type="button" value="Grabar y Nuevo" onclick="$('typeSubmit').value='add'; events('submit');"/>
                  <input class="button" type="button" value="Grabar" onclick="$('typeSubmit').value='list'; events('submit');"/>
                	<input class="button" type="button" value="Cancelar" onclick="parent.objMainTab.reqBody('<?=buildUrl('te/list')?>','001')" />
                  </div>
          </td>
        </tr>
       </table>
       </fieldset>

    </td>
  </tr>
</table>



<script type="text/javascript">
	function formCallback(result, form) {
		window.status = "valiation callback for form '" + form.id + "': result = " + result;
	}
	var valid = new Validation('form1', {immediate : true});
</script>

<script>
//----------------------------------------------------------------------------------------//
var grid = new formItem("idGrid",{objInstance:'grid'});
//se especifica q caracteristicas tendra cada celda
grid.options.data = ['s', 'iSelect', 'iText', 's', 'iText'];
//alineacion de cada linea
grid.options.alignTd = ['center', 'center', 'center', 'left', 'center'];
//valor por defecto solo para movimiento
var attributes = [];
attributes[1]  = {'class':'', onblur:"", onChange:"actionSelect(this);", style:""};
attributes[2]  = {size:"8", 'class':'text mayus', onfocus:"this.select();", style:"text-align:center;", onblur:"actionCod(this);", onkeydown:"buscaDetalle(event,this);"};
attributes[4]  = {size:"5", 'class':'text mayus', onfocus:"this.select();", style:"text-align:center;visibility:hidden"};
grid.options.attribute = attributes;
//nombre de las variables a retornar
var namesVar = [];
namesVar[0] = "count";
namesVar[1] = "tipo[]";
namesVar[2] = "codigo[]";
namesVar[4] = "part[]";
grid.options.varOutput = namesVar;
//debe de validar antes de insertar y se reutiliza para grabar
grid.options.rowValidate = [2,3];
//----------------------------------------------------------------------------------------//
</script>
