<?php use_helper('UrlFunctions'); ?>
<?php use_helper('UtilFunctions');?>
<script>

acutalizarEspecialidad = function(destino,elm){
  $(destino).options.length = 1;
  var url = '<?=buildUrl('ajax/request')?>';
  var pars = 'type=getEspecialidad&nombreElm='+destino+'&value='+elm.value;
  
	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>

<?php

if(isset($control)){

	$o_MstPersonaDP =  new MstPersonaDP();
	
	$o_MstPersonaDP->setRucdni($rucdni);
	$nombrecompleto = $nombres." ".$apellidopaterno." ".$apellidomaterno;
	$o_MstPersonaDP->setNombrecompleto($nombrecompleto);
	$o_MstPersonaDP->setNombres($nombres);
	$o_MstPersonaDP->setFlagsecretarioarbitral(1);;
	$o_MstPersonaDP->setApellidopaterno($apellidopaterno);
	$o_MstPersonaDP->setApellidomaterno($apellidomaterno);
	$o_MstPersonaDP->setTemporal($contrasena);
	$o_MstPersonaDP->setUsuarioweb($usuario);
	$o_MstPersonaDP->setFechacreacion(date("Y-m-d H:i:s"));
	$o_MstPersonaDP->setUsuariocreacion(myUser::getUser()->getUserId());
	$bResult = $o_MstPersonaDP->save();
  
	$o_MnuUserDP = new MnuUserDP();
	$o_MnuUserDP->setUserId($usuario);
	$o_MnuUserDP->setUserName($nombres);
	$o_MnuUserDP->setPswdChgDate(date("Y-m-d H:i:s"));
	$o_MnuUserDP->setRoleId("sys.sec");
	$o_MnuUserDP->setCreatedDate(date("Y-m-d H:i:s"));
	$o_MnuUserDP->setCreatedUser(myUser::getUser()->getUserId());
	$o_MnuUserDP->setIsDisabled("N");
	$o_MnuUserDP->setInUse("N");
	$o_MnuUserDP->setUserPassword($contrasena);
	$o_MnuUserDP->save();
	
  
  //exit;
	if($bResult > 0){
		?>
		<script language="JavaScript">
		parent.objMainTab.reqBody('<?=buildUrl('secretarioarbitral/list')?>','001&msg=Se registro al secretario arbitral');
		parent.objMainTab.windowsCloseAll();
		</script>
		<?
	}else{
	$mensaje = $bResult;
	}
  
}

 	
   
?>

<img src="/images/common/spacer.gif" width="10">
<table class="cuerpo" width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td height="0">
		  <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
			  <td class="titleBody"><li>Nuevo Secretario Arbitral</li></td>
			</tr>
		  </table>
		</td>
	</tr>
    
	<tr>
		<td valign="top">
			<form id="form1" name="form1" method="POST" enctype="multipart/form-data">
				<input type="hidden" name="control" value="1">
		  
				<table hspace="20px" class="marco" width="96%">
					<tr>
						<td valign="top" colspan="2">
				
							<table hspace="1px"  width="100%" style="border:1px solid #d3d3d3; min-height:220px">
								<tr>
									<td height="0">
								  
										<table width="100%" border="0" cellspacing="6" cellpadding="0">
										   
											<tr>
												<td width="20%"><label class="label">Dni</label></td>
												<td nowrap="nowrap"><input class="text" title="Ingrese el ruc" type="text" name="rucdni" id="rucdni" size="35" maxlength="8" value=""/></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
											<tr>
												<td width="10%" ><label class="label">Nombres</label></td>
												<td nowrap="nowrap"><input class="text required" title="Ingrese el nombre" type="text" name="nombres" id="nombres" size="35" maxlength="120" value=""/></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
											<tr>
												<td width="10%" ><label class="label">Apellido paterno</label></td>
												<td nowrap="nowrap"><input class="text required" title="Ingrese el Apellido paterno" type="text" name="apellidopaterno" id="apellidopaterno" size="35" maxlength="120" value=""/></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
											<tr>
												<td width="10%" ><label class="label">Apellido materno</label></td>
												<td nowrap="nowrap"><input class="text required" title="Ingrese el Apellido materno" type="text" name="apellidomaterno" id="apellidomaterno" size="35" maxlength="120" value=""/></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
											<tr>
												<td width="10%" ><label class="label">Usuario</label></td>
												<td nowrap="nowrap"><input class="text" title="Ingrese la usuario" type="text" name="usuario" id="usuario" size="35" maxlength="30" value=""/></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>										
											<tr>
												<td width="10%" ><label class="label">Contraseña</label></td>
												<td nowrap="nowrap"><input class="text required" title="Ingrese la contraseña" type="text" name="contrasena" id="contrasena" size="35" maxlength="8" value=""/></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>										
											
										</table>
												
									</td>
								</tr>
								<tr>
									<td height="0" width="100%">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td><img src="/images/common/spacer.gif" width="10"></td>
											</tr>
											<tr>
											  <td align="center">
											  <input type="hidden" name="typeSubmit" id="typeSubmit">
											  <input type="hidden" name="noredir" id="noredir" value="<?=$noredir?>">
											  <input class="button" type="submit" value="Grabar" onclick="$('typeSubmit').value='list';">
											  <input class="button" type="button" value="Cancelar" onclick="document.location.href='<?=buildUrl('texto/list',"block=001")?>';"/>
											  </td>
											</tr>
											<tr>
												<td height="10">&nbsp;</td>
											</tr>
										</table>
								
									</td>
								</tr>
							
							</table>
							
							
						</td>
					</tr>
				</table>
			</form>
				<script type="text/javascript">
					$("#form1").validate();
				 </script>
		</td>
	</tr>
</table>
