<?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>

	function loadProvincias(destino,idDept,idProv){
		$(destino).options.length = 1;
		$('cboDisitrio').options.length = 1;
		var url = '<?=buildUrl('ajax/request')?>';
		var pars = 'type=getProvincias&nombreElm='+destino+'&value='+idDept+'&Edefault='+idProv;
		  
		var myAjax = new Ajax.Request(
		                       		url, 
		                          		{
		                          			method: 'get', 
		                           			parameters: pars, 
		                          			onComplete: actualizaJSON
		                           		});	
	}
	
	function loadDistritos(destino,idProv,idDist){
		$(destino).options.length = 1;
		var url = '<?=buildUrl('ajax/request')?>';
		var pars = 'type=getDistritos&nombreElm='+destino+'&value='+idProv+'&Edefault='+idDist;
		  
		var myAjax = new Ajax.Request(
		                       		url, 
		                          		{
		                          			method: 'get', 
		                           			parameters: pars, 
		                          			onComplete: actualizaJSON
		                           		});	
	}
	
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 selct	= a_contentValues[2];
	      	  if( selct == 'selected'){
	      	  	alert('xxxxxxxxxxxxxxxxxxxxxx'+value);
	  	      	var option	= new Option(text,value,"defauldSelected");
	      	  }else{
	      	  	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
//echo myUser::getUser()->getRoleId();
//error_reporting(E_ALL);
//ini_set('display_errors','On'); //PARA PRODUCCION "Off"

if(isset($control)){
  
	$o_ArBancoDP = new ArBancoDP();
	
	$o_ArBancoDP->setDescripcion($Descripcion);
	$o_ArBancoDP->setEstado( $cboEstado );
	$o_ArBancoDP->setFechamodificacion( date( "Y-m-d H:i:s" ) );
	$o_ArBancoDP->setUsuariomodificacion( $s_User );
	$b_Result = $o_ArBancoDP->update();
 
  
    if($bResult)
    {
        if( $typeSubmit == "next" )
        {
            ?>
            <script language="JavaScript">
            location.href = "<?php echo buildUrl( 'bancocta/listctas', "id={$id}" ) ?>";
            </script>
            <?
        }
        else 
        {
            ?>
            <script language="JavaScript">
            location.href = "<?php echo buildUrl( 'bancocta/bancocta', "id={$id}" ) ?>";
            </script>
            <?
        }
    }
    else
    {
        //$url = buildUrl('cli/add', "block=".$block."&error=1");
        echo '<div class="ui-widget" style="margin: 2px;"><div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"><p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span><strong>Error:</strong>Error en actualizar el cliente.</p></div></div>';
    }
}

 

$o_ArBancoFN = new ArBancoFN();
$o_ArBancoFN->setIdbanco($id);
$a_ObjectBean = $o_ArBancoFN->select();


if(is_array($a_ObjectBean)){
  while(list($key,$o_ObjectBean) = each($a_ObjectBean)){
  	
  	
  	
 	
?>
<table class="cuerpo" width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td valign="top">
			 <form id="form1" name="form1" method="POST">
				<input type="hidden" name="control" value="1">
			  
                        <?php
                        $s_Param = '';
                        if( isset( $id ) )
                        {
                            $s_Param = 'id='.$id;
                        }
                        ?>
			  
                        <table id="tabShowScan" cellpadding="0" cellspacing="0" class="" style="margin-top: 5px;">
                            <tr>
                              <td class="mnuActivoIzq" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="7"></td>
                              <td class="mnuActivoTxt" type='maintTabguiaGeneral' nowrap onclick="location.href='<?php echo buildUrl('bancocta/editbanco', $s_Param) ?>';">Banco</td>
                              <td class="mnuActivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="10"></td>
							  
                              <?php if( isset( $id ) && $id != "" ){ ?>
                              <td class="mnuInactivoIzq" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="7"></td>
                              <td class="mnuInactivoTxt" type='maintTabguiaGeneral' nowrap onclick="location.href='<?php echo buildUrl('bancocta/listctas', $s_Param) ?>';">Cuentas Bancarias</td>
                              <td class="mnuInactivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="10"></td>
                              <td class="mnuSep"><img src="/images/common/spacer.gif"></td>
                        <?php } ?>
                            </tr>
                        </table>
			  
                        <table width="100%" cellspacing="2" cellpadding="2" border="0" class="marco" style="width:100%">
							
						
                            <tr>
                                <td nowrap="nowrap">
                                    
                                        
                                    	<table width="100%">
                                    	
                                            <tr>
                                                <td width="50%">
    
                                                    <table width="100%" cellpadding="5" border="0">
                                                      
                                                        <tr>
                                                            <td width="12%"><label class="label">Descripcion </label></td>
                                                            <td><input class="text required" id="Descripcion" name="Descripcion" size="40" type="text" class="text" value="<?php echo $o_ObjectBean->getDescripcion();?>"/></td>
                                                        </tr>
                                                        
                                                        <tr>
                                                            <td><label class="label" >Estado</label></td>
                                                            <td>
                                                                <select name="cboEstado" id="cboEstado" type="text" class="combo"/> 
                                                                    <option value="" >Seleccione</option>
                                                                    <option value="A" <?php  if($o_ObjectBean->getEstado() == 'A') echo "selected='selected'"?>>Activo</option>
                                                                    <option value="I" <?php  if($o_ObjectBean->getEstado() == 'I') echo "selected='selected'"?>>Inactivo</option>
                                                                </select>
                                                            </td>
                                                        </tr>
													</table>
                                                </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='ok';">
													<input class="button" type="submit" value="Grabar y Siguiente" onclick="$('typeSubmit').value='next';">
													<input class="button" type="button" value="Siguiente" onclick="location.href='<?php echo buildUrl('bancocta/listctas', $s_Param) ?>'"/>
													<input class="button" type="button" value="Cancelar" onclick="location.href='<?php echo buildUrl('bancocta/list', $s_Param."&block=001") ?>'"/>
												</td>
											</tr>
											<tr>
												<td height="10">&nbsp;</td>
											</tr>
									</table>   
                                </td>
                            </tr>
                        </table>
                        
                        
                        
							      
				
			</form>
				<script type="text/javascript">
					var valid = new Validation('form1', {immediate : true});
				</script>
		</td>
	</tr>
</table>


<?php
  }
}
?>
<script>
	//loadProvincias('cboProvincia','<?=$idDpto?>','<?=$idProv?>');
	//loadDistritos('cboDisitrio','<?=$idProv?>','<?=$idDist?>');
</script>

