<?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_ConvAuspiciadoresDP = new ConvAuspiciadoresDP();
  
  $o_ConvAuspiciadoresDP->setNombre($Nombre);
  $o_ConvAuspiciadoresDP->setUrl(nameToURL($Nombre));

  $o_ConvAuspiciadoresDP->setNumeroOrden($NumeroOrden); 
  $o_ConvAuspiciadoresDP->setEstado($cboEstado);
  $o_ConvAuspiciadoresDP->setImagen(nameToURL($Nombre));
  //if(!$otraventana) $otraventana = '-1';
  //$o_BannerDP->setOtraventana($otraventana);
  $o_ConvAuspiciadoresDP->setUsuarioCreacion(myUser::getUser()->getUserId());
  $o_ConvAuspiciadoresDP->setFechaCreacion(date("Y-m-d H:i:s"));
  $bResult = $o_ConvAuspiciadoresDP ->save();
	
  if($bResult){
  	if(is_array($_FILES)){
  		//Armar un array
  		
  		$o_ConvAuspiciadoresDP->updateImagenes2(nameToURL($Nombre));
		//if($o_file->subir_docinfo($_FILES,"pro_foto_chica","pro_foto_chica_".$itemId.".jpg",Constantes::PATH_FILE_IMAGE )){
		  
		//}
  	}
    ?>
    <script language="JavaScript">
    parent.objMainTab.reqBody('<?=buildUrl('auspiciador/list')?>','&block=001&insert=1&cod=<?=''?>');
    parent.objMainTab.windowsCloseAll();
    </script>
    <?
  }else{
    $url = buildUrl('auspiciador/add', "block=".$block."&error=1");
  }
  exit;
}

/*$o_marca = new SgMstMarcaFN();
$o_marca ->setEstado('A');
$a_o_marca=$o_marca->select();*/

?>
<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>Nueva entidad</li>
				</td>
			  <td align="right" valign="baseline">&nbsp;</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="5px" class="marco" width="99%">
					<tr>
						<td valign="top">
							<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 nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="txtRucdni" >Ruc</label></td>
												<td nowrap="nowrap"><input class="text required" type="text" name="rucdni" id="rucdni" size="45" maxlength="11" /></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
											<tr>
												<td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="txtcodigo" >Nombre</label></td>
												<td nowrap="nowrap"><input class="text required" type="text" name="nombrecompleto" id="nombrecompleto" size="45" maxlength="80" /></td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
											<tr>
												 <td width="5%" height="26" nowrap="nowrap" class="cabecera"><label class="label" for="txtCliente">Estado</label></td>
												 <td nowrap="nowrap" align="left">
													 <select name="cboEstado" id="cboEstado" type="text" class="combo" onchange="acutalizarEspecialidad('cboEspecialidad',this)"/> 
													   <option value="A">Activo</option>
													   <option value="I">Inactivo</option>
													</select>
												</td>
												<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
											</tr>
										</table>
										<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 class="button" type="submit" value="Grabar" onclick="$('typeSubmit').value='list';">
											  <input class="button" type="button" value="Cancelar" onclick="parent.objMainTab.windowsCloseAll();"/>
											</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>
