<?php use_helper('UrlFunctions'); ?>
<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_CapitalInicialBean = new CapitalInicialBean();
  
  $o_CapitalInicialBean->setIdCapitalInicial($id);
  $o_CapitalInicialBean->setIdColaborador($cboColaborador);
  $o_CapitalInicialBean->setMonto($Monto);
  $o_CapitalInicialBean->setFecha(date($Fecha));
  $o_CapitalInicialBean->setEstado($cboEstado);
  $o_CapitalInicialBean->setEliminado($Eliminado);
  $o_CapitalInicialBean->setFechaModificacion(date("Y-m-d"));
  $o_CapitalInicialBean->setUsuarioModificacion(myUser::getUser()->getUserId());
  
  $o_CapitalInicialSystemClass = new CapitalInicialSystemClass($o_CapitalInicialBean);
  $bResult = $o_CapitalInicialSystemClass->actualizarCapitalInicial();
  
  if($bResult){
    ?>
    <script language="JavaScript">
    parent.objMainTab.reqBody('<?=buildUrl('iop/list')?>','&block=001&insert=1&cod=<?=$o_CapitalInicialBean->getIdCapitalInicial()?>');
    parent.objMainTab.windowsCloseAll();
    </script>
    <?
  }else{
    $url = buildUrl('iop/add', "block=".$block."&error=1");
  }
  exit;
}
	$o_CapitalInicialSystemClass = new CapitalInicialSystemClass(new ColaboradorBean());
	$a_Colaborador = $o_CapitalInicialSystemClass->getColaborador();

	$o_CapitalInicialBean = new CapitalInicialBean();
	$o_CapitalInicialBean->setIdCapitalInicial($id);
	$o_class = new CapitalInicialBL();
	$o_ObjectBean = $o_class->busquedaCapitalInicial($o_CapitalInicialBean);
 
 ?>
 
<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>Caja</li>
            <span class="subtitle"><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:::&nbsp;Ficha de Asignación de Caja</I></span></td>
          <td align="right" valign="baseline">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
      <script type="text/javascript">
        validatePass = function(){
          
            valid.onSubmit = false;
          
        }
      </script>
  <tr>
    <td valign="top">
      <form id="form1" name="form1" method="POST">
      <input type="hidden" name="control" value="1">
        <table hspace="20px" class="marco" width="99%">
          <tr>
            <td valign="top">
              <table width="100%" border="0" cellpadding="5" cellspacing="0" style="background: #E3E9E2">
          		<tr>
    				  <td height="0">
    				  <fieldset>
    					<legend class="fielsettex"><I>Datos Generales</I></legend>
    					 <table width="100%" border="0" cellspacing="6" cellpadding="0">
							  
							  <tr>
                  				<td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="txtAdministrador" >Representante</label></td>
                  				 <td nowrap="nowrap"><label class="label" for="txtEspecialidadIdD">
                    				<?php foreach ($a_Colaborador as $iKey => $o_ColaboradorBean){ 
                            			if($o_ColaboradorBean->getIdColaborador() == $o_ObjectBean->getIdColaborador()){
                              			  echo $o_ColaboradorBean->getNombres();
                            			}
                          				}
                   					?></label>
                   				</td>
                				<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
                 			    <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="txtMonto" >Monto</label></td>
  								<td width="38%" nowrap="nowrap"><label class="label" for="Monto"><?=$o_ObjectBean->getMonto() ?></label></td>
  								
							  </tr>
							  <tr>
							    <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="txtEstado" >Estado</label></td>
								<td width="38%" nowrap="nowrap"><label class="label" for="Estado"><? if ($o_ObjectBean->getEstado()=='A'){ echo "Activo";} else { echo "Inactivo";}?></label></td>
								<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
                 			    <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="txtFecha" >Fecha Entrega</label></td>
  								<td width="38%" nowrap="nowrap"><label class="label" for="Fecha"><?=$o_ObjectBean->getFecha() ?></label></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="button" value="Cerrar" onclick="parent.objMainTab.windowsCloseAll();"/>
								</td>
							  </tr>
							  <tr>
								<td height="10">&nbsp;</td>
							  </tr>
							</table>
    					</fieldset>				
    				</td>
                </tr>
      </table>
      </form>
			<script type="text/javascript">
				var valid = new Validation('form1', {immediate : true});
			</script>
    </td>
  </tr>
</table>
