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

<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>Cliente</li>
            <span class="subtitle"><I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:::&nbsp;Mostrar Cliente</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="txtDniCliente" >DNI </label></td>
								<td width="38%" nowrap="nowrap"><label class="label" for="Dni">&nbsp;:&nbsp;<?=$o_ObjectBean->getDni() ?></label></td>
								 <td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
								 <td width="12%" nowrap="nowrap" class="cabecera"><label class="label req" for="txtSexo" >Sexo</label></td>
								  <td width="38%" nowrap="nowrap"><label class="label" for="Sexo">&nbsp;:&nbsp;<? if ($o_ObjectBean->getSexo()=='F'){ echo "Femenino";} else { echo "Masculino";}?></label></td>
							   </tr>
							   <tr>
								<td nowrap="nowrap" class="cabecera"><label class="label req" for="txtNombres" >Nombres </label></td>
								<td width="38%" nowrap="nowrap"><label class="label" for="Nombres">&nbsp;:&nbsp;<?=$o_ObjectBean->getNombres() ?></label></td>
								<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
								 <td width="12%" nowrap="nowrap" class="cabecera"><label class="label req" for="txtEsatdoCivil" >Estado Civil</label></td>
								  <td width="38%" nowrap="nowrap"><label class="label" for="EstadoCivil">&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 nowrap="nowrap" width="12%" class="cabecera"><label class="label" for="txtApellidoPaterno">Apellido Paterno </label></td>
								<td width="38%" nowrap="nowrap"><label class="label" for="ApellidoPaterno">&nbsp;:&nbsp;<?=$o_ObjectBean->getApellidoPaterno() ?></label></td>
								 <td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
								 <td width="12%" nowrap="nowrap" class="cabecera"><label class="label req" for="txtFechaNacimiento" >F. Nacimiento</label></td>
								 <td width="38%" nowrap="nowrap"><label class="label" for="FechaNacimiento">&nbsp;:&nbsp;<?=$o_ObjectBean->getFechaNacimiento() ?></label></td>
							  </tr>
							  
							  <tr>
								<td nowrap="nowrap" width="12%" class="cabecera"><label class="label" for="txtApellidoMaterno" >Apellido Materno </label></td>
								<td width="38%" nowrap="nowrap"><label class="label" for="ApellidoMaterno">&nbsp;:&nbsp;<?=$o_ObjectBean->getApellidoMaterno() ?></label></td>
								<td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
								<td nowrap="nowrap" width="12%" class="cabecera"><label class="label" for="txtApellidoMaterno" >Mercado</label></td>
								<td nowrap="nowrap"><label class="label" for="txtEspecialidadIdD">&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 nowrap="nowrap" width="12%" class="cabecera"><label class="label" for="txtDireccion">Direcci&oacute;n</label></td>
								<td nowrap="nowrap" width="38%">&nbsp;:&nbsp;<label class="label" for="txtDireccion" ><?php echo $o_ObjectBean->getDireccion();?></label></td>
								 <td nowrap="nowrap" width="12%" class="cabecera">&nbsp;</td>
								 <td width="12%" nowrap="nowrap" class="cabecera"><label class="label req" for="txtEmail" >Tipo Negocio</label></td>
								 <td nowrap="nowrap">&nbsp;:&nbsp;<label class="label" for="txtEspecialidadIdD">
                    				<?php foreach ($a_TipoNegocio as $iKey => $o_TipoNegocioBean){ 
                            			if($o_TipoNegocioBean->getIdTipoNegocio() == $o_ObjectBean->getIdTipoNegocio()){
                              			  echo $o_TipoNegocioBean->getDescripcion();
                            			}
                          				}
                   					?></label>
                   				</td>
							  </tr>
							  <tr>
							   <td nowrap="nowrap" width="12%" class="cabecera"><label class="label" for="txtEstado">Estado</label></td>
								<td width="38%" nowrap="nowrap"><label class="label" for="Estado">&nbsp;:&nbsp;<? if ($o_ObjectBean->getEstado()=='A'){ echo "Activo";} else { echo "Inactivo";}?></label></td>
								<td nowrap="nowrap" width="12%" class="cabecera">&nbsp;</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">
  					      <fieldset>
					 		<legend class="fielsettex"><I>Otros Datos</I></legend>
  					        <table width="50%" border="0" cellspacing="3" cellpadding="0">
	  					         <tr>
									<td nowrap="nowrap" width="12%" class="cabecera"><label class="label" for="txtDireccion">Tel&eacute;fono</label></td>
						            <td width="38%" nowrap="nowrap"><label class="label" for="Telefono"><?=$o_ObjectBean->getTelefono() ?></label></td>
						 
								  </tr>
								  <tr>
								     <td nowrap="nowrap" width="12%" class="cabecera"><label class="label" for="txtCelular">Celular</label></td>
						 <td width="38%" nowrap="nowrap"><label class="label" for="Celular"><?=$o_ObjectBean->getCelular() ?></label></td>
								  </tr>
  					        </table>
  					      </fieldset>
  					    </td>
  					    <td valign="top">
  					      <fieldset>
					 		<legend class="fielsettex"><I>Documentos Adjuntos</I></legend>
  					        <table width="100%" border="0" cellspacing="5" cellpadding="0">
  					          <?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="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>
  				 <!-- <td height="0">
				    <fieldset>
					 <legend class="fielsettex"><I>Otros Datos</I></legend>
  					 <table width="100%" border="0" cellspacing="5" cellpadding="0">
					  <tr>
						 <td nowrap="nowrap" width="12%" class="cabecera"><label class="label" for="txtDireccion">Tel&eacute;fono</label></td>
						 <td width="38%" nowrap="nowrap"><label class="label" for="Telefono"><?=$o_ObjectBean->getTelefono() ?></label></td>
						 <td nowrap="nowrap" width="12%" class="cabecera"><label class="label" for="txtCelular">Celular</label></td>
						 <td width="38%" nowrap="nowrap"><label class="label" for="Celular"><?=$o_ObjectBean->getCelular() ?></label></td>
						 <td nowrap="nowrap" width="12%" 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>
				 
  				
				</fieldset>
          		</td>-->
        		</tr>
				<tr>
      			</table>
     		</form>
			<script type="text/javascript">
				var valid = new Validation('form1', {immediate : true});
			</script>
			</td>
  		  </tr>
		</table>
    </td>
  </tr>
</table>
<?php
  }
}
?>

