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


  //Mercados
  $o_ClienteSystemClass = new ClienteSystemClass(new MercadoBean());
  $a_Mercado = $o_ClienteSystemClass->getMercado();
  
  //Tipos de Negocio
  $o_ClienteSystemClass = new ClienteSystemClass(new TipoNegocioBean());
  $a_TipoNegocio = $o_ClienteSystemClass->getTipoNegocio();

//Cargar Documento
$o_ClienteSystemClass = new ClienteSystemClass(new DocumentoBean());
$a_o_Documento = $o_ClienteSystemClass->getDocumento();

$o_DocumentoClienteBean = new DocumentoClienteBean();
$o_DocumentoClienteBean->setIdCliente($id);
$o_DocumentoClienteBL = new DocumentoClienteBL();
$a_o_documento = $o_DocumentoClienteBL->busquedaDocumentoClienteDetalle($o_DocumentoClienteBean);
if(is_array($a_o_documento)){
	foreach ($a_o_documento as $key =>$o_documento){
		$a_id_documento[] = $o_documento->getIdDocumento();
	}
}

  

$o_ClienteBean = new ClienteBean();
$o_ClienteBean->setIdCliente($id);
$o_class = new ClienteBL();
$a_ObjectBean = $o_class->busquedaCliente($o_ClienteBean);

if(is_array($a_ObjectBean)){
  while(list($key,$o_ObjectBean) = each($a_ObjectBean)){
?>

<table class="cuerpo" width="100%" border="0" cellpadding="0" cellspacing="0">
	<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="2px" class="marco" width="96%" cellpadding="0" cellspacing="0">
					<tr>
						<td valign="top" colspan="2">
					
								<table width="100%" border="0" cellpadding="0" cellspacing="0" style="background: #fff">
									<tr>
										<td height="0">
											<fieldset>
												<legend class="fielsettex">DATOS DEL CLIENTE</legend>
												<table width="100%" border="0" cellspacing="0" cellpadding="1">
													    <tr>
															 <td width="5%"><label class="label">DNI </label></td>
															 <td width="5%"><label class="label">&nbsp;:&nbsp;<?=$o_ObjectBean->getDni() ?></label></td>
															 <td width="1%">&nbsp;</td>
															 <td width="5%"><label class="label" >Sexo</label></td>
															 <td nowrap="nowrap" width="5%"><label class="label">&nbsp;:&nbsp;<? if ($o_ObjectBean->getSexo()=='F'){ echo "Femenino";} else { echo "Masculino";}?></label></td>
													   </tr>
														<tr>
															<td width="5%"><label class="label" >Nombres </label></td>
															<td width="5%"><label class="label">&nbsp;:&nbsp;<?=$o_ObjectBean->getNombres() ?></label></td>
															<td width="1%">&nbsp;</td>
															<td width="5%"><label class="label" >Estado Civil</label></td>
															<td  width="5%"><label class="label">&nbsp;:&nbsp;
																	 <? if ($o_ObjectBean->getEstadoCivil()=='C')
																		 { echo "Casado";} 
																			 else if($o_ObjectBean->getEstadoCivil()=='S')
																			 { echo "Soltero";}
																				 else
																				  { echo "Viudo";}
																		   ?></label>
															</td>
														</tr>
														<tr>
															<td  width="5%" ><label class="label">Apellido Paterno </label></td>
															<td nowrap="nowrap" width="5%"><label class="label">&nbsp;:&nbsp;<?=$o_ObjectBean->getApellidoPaterno()?></label></td>
															<td width="1%">&nbsp;</td>
															<td width="5%"><label class="label">F. Nacimiento</label></td>
															<td width="5%"><label class="label">&nbsp;:&nbsp;<?=$o_ObjectBean->getFechaNacimiento()?></label></td>
														</tr>
													  <tr>
															<td  width="5%" ><label class="label">Apellido Materno </label></td>
															 <td nowrap="nowrap" width="5%"><label class="label">&nbsp;:&nbsp;<?=$o_ObjectBean->getApellidoMaterno() ?></label></td>
															 <td width="1%">&nbsp;</td>
															 <td width="5%"><label class="label">Mercado</label></td>
															 <td width="5%"><label class="label">&nbsp;:&nbsp;
																	<?php foreach ($a_Mercado as $iKey => $o_MercadoBean){ 
																		if($o_MercadoBean->getIdMercado() == $o_ObjectBean->getIdMercado()){
																		  echo $o_MercadoBean->getDescripcion();
																		}
																		}
																	?></label>
															  </td>
														</tr>
														<tr>
															<td width="5%"><label class="label">Direcci&oacute;n Domiciliaria</label></td>
															<td  width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getDireccion();?></label></td>
															<td width="1%">&nbsp;</td>
															<td width="5%"><label class="label">Actividad Comercial</label></td>
															<td width="5%"><label class="label">&nbsp;:&nbsp;
																<?php foreach ($a_TipoNegocio as $iKey => $o_TipoNegocioBean){ 
																	if($o_TipoNegocioBean->getIdTipoNegocio() == $o_ObjectBean->getIdTipoNegocio()){
																	  echo $o_TipoNegocioBean->getDescripcion();
																	}
																	}
																?></label>
															</td>
														</tr>
											            <tr>
															<td width="5%"><label class="label">Referencia Domiciliaria</label></td>
															<td  width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getReferenciaDomiciliariaCliente();?></label></td>
															<td width="1%">&nbsp;</td>
															<td colspan="3" width="5%">
																 <table cellspacing="0" cellpadding="0">
																	
																	<tr class="lblSmall">
																		<td width="35%"><label class="label" >Departamento</label></td>
																		<td>
																			<label class="label">&nbsp;:&nbsp;
															                       <?php   echo $o_ObjectBean->getNombreDepartamento();?>
															                 </label>
																		</td>
																	</tr>
																	<tr>
																		<td><label class="label">Provincia</label></td><td>
																		<label class="label">&nbsp;:&nbsp;
														                    	<?php   echo $o_ObjectBean->getNombreProvincia();?>
														                 </label>
																		</td>
																	</tr>
																	<tr>
																		<td ><label class="label">Distrito</label></td><td>
																			<label class="label">&nbsp;:&nbsp;
														                     	<?php   echo $o_ObjectBean->getNombreDistrito();?>
														               		</label>
																		</td>
																	</tr>
																</table> 
															</td>
														</tr>
														<tr>
															<td width="5%"><label class="label">Direcci&oacute;n Donde Labora</label></td>
															<td  width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getDireccionlabora();?></label></td>
															<td width="1%">&nbsp;</td>
															<td width="5%"><label class="label">Referencia Donde Labora</label></td>
															<td  width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getReferenciaLabora();?></label></td>
														</tr>
														<tr>
															<td width="5%"><label class="label">Telefono</label></td>
															<td width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getTelefono();?></label></td>
															<td width="1%">&nbsp;</td>
															<td width="5%"><label class="label">Celular</label>
															<td width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getCelular();?></label></td>
														</tr>                    		
														<tr>
															<td width="5%"><label class="label">RPC</label></td>
															<td width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getRpc();?></label></td>
															<td width="1%">&nbsp;</td>
															<td width="5%"><label class="label">RPM</label>
															<td width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getRpm();?></label></td>
														</tr>
														<tr>
															<td width="5%"><label class="label">Nextel</label></td>
															<td width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getNextel();?></label></td>
															<td width="1%">&nbsp;</td>
															<td width="5%"><label class="label">Fecha Inicio Negocio</label>
															<td width="5%"><label class="label">&nbsp;:&nbsp;<?=$o_ObjectBean->getFechaInicioNegocio()?></label></td>
														</tr>
														<tr>
															<td width="5%"><label class="label">Estado</label></td>
															<td width="5%"><label class="label">&nbsp;:&nbsp;<? if ($o_ObjectBean->getEstado()=='A'){ echo "Activo";} else { echo "Inactivo";}?></label></td>
															<td width="1%">&nbsp;</td>
															<td width="5%"><label class="label">&nbsp;</label>
															<td width="5%"><label class="label">&nbsp;</label></td>
														</tr> 
														
												</table>
											</fieldset>				
										</td>
									</tr>
									<tr>
										<td colspan="5">
											<fieldset>
												<legend class="fielsettex">REFERENCIA BANCARIA</legend>
												<table  border="0" cellspacing="4" cellpadding="4">
													 <tr>
														<td width="8%" ><label class="label">Banco 1</label></td>
														<td><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getBanco1();?></label></td>
														<td width="12%"><label class="label">Nro Cuenta 1</label></td>
														<td><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getNumeroCuenta1();?></label></td>
													  </tr>
													  <tr>
														<td  width="8%"><label class="label">Banco 2 </label></td>
														<td><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getBanco2();?></label></td>
														<td width="12%"><label class="label">Nro Cuenta 2</label></td>
														<td><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getNumeroCuenta2();?></label></td>
													  </tr>
													  <tr>
														<td  width="8%"><label class="label">Infocor&nbsp;&nbsp;</label></td>
														<td width="5%"><label class="label">&nbsp;:&nbsp;<? if ($o_ObjectBean->getFlagInfocor()=='S'){ echo "Si";} else { echo "No";}?></label></td>
														<td width="12%"><label class="label">Linea Credito</label></td>
														<td><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getLineaCredito();?></label></td>
													  </tr>
												</table>
											</fieldset>
										</td>
									</tr>
									<tr>
										<td colspan="5">
											<fieldset >
												<legend class="fielsettex">DATOS DEL AVAL</legend>
												<table  border="0" cellspacing="4" cellpadding="4">
													<tr>
														<td width="8%"><label class="label">DNI </label></td>
														<td width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getDniAval();?></label></td>
														<td  width="10%"><label class="label">Nombres y Apellidos</label></td>
														<td width="15%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getNombreApellidoAval();?></label></td>
													</tr>													 
													<tr>
														<td  width="8%"><label class="label">Fecha Nacimiento</label></td>
														<td width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getFechaNacimientoAval();?></label></td>
													</tr>
													<tr>
														<td width="5%"><label class="label">Direcci&oacute;n Domiciliaria</label></td>
														<td  width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getDireccionAval();?></label></td>
														<td width="5%"><label class="label">Referencia Domiciliaria</label></td>
														<td  width="5%"><label class="label">&nbsp;:&nbsp;<?php echo $o_ObjectBean->getReferenciaAval();?></label></td>
													</tr>
												</table>
											</fieldset>
										</td>
									</tr>
									<tr>
										<td height="0" width="100%">
										   
												<table width="100%" border="0" cellspacing="5" cellpadding="0">
													<tr>
														
														<td valign="top" width="50%">
															<fieldset>
																<legend class="fielsettex">DOCUMENTOS ADJUNTOS</legend>
																<table width="100%" border="0" cellspacing="4" cellpadding="4">
																	 <?php   
																			if(is_array($a_o_Documento) && is_array($a_id_documento)){
																				$i = 1;
																				while(list($key,$o_Documento) = each($a_o_Documento)){
																					if($i == 1){ ?>
																						<tr>
																					<?}?>
																						<?php 
																						if(in_array($o_Documento->getIdDocumento(),$a_id_documento)){ 
																							echo "<td width='4%'>";
																							echo "<label class='label'>".$o_Documento->getDescripcion()."</label>";
																							echo "</td>";
																							$i++;
																						}
																						?>
																					<?php
																					if($i == 3){ 
																						$i = 1;?>
																						</tr>
																					<?}?><?php
																				}
																			}
																		?>
																</table>
															</fieldset>
														</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="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">
					var valid = new Validation('form1', {immediate : true});
				</script>
		</td>
	</tr>
</table>
<?php
  }
}
?>

