<?php use_helper('UrlFunctions'); ?>
<?php use_helper('UtilFunctions'); ?>
<?php
//error_reporting(E_ALL);
//ini_set('display_errors','On'); //PARA PRODUCCION "Off"

?>
<?php
$a_clasificacion = getListadoClasificacionInfocorp();
$s_User = myUser::getUser()->getUserId();
$s_Param = '';
if( isset( $id ) )
{
    $s_Param = 'id='.$id;
}
if( isset( $control ) )
{
	 $o_ClienteBean = new ClienteBean();
  
	if($flaginfocorp=="N" || $flaginfocorp=="F"){
		$scoreinfocorp = '0.00';
		$clasificacion = '';
		$o_ClienteBean->setClasificacionInfocorp(' ');
		$o_ClienteBean->setColorInfocorp(' ');
	}else{
		$o_clasificacion = getClasificacionInfocorp($scoreinfocorp);
  		$o_ClienteBean->setClasificacionInfocorp($o_clasificacion->descripcion);
  		$o_ClienteBean->setColorInfocorp($o_clasificacion->color);
	}
	$scoreinfocorp2 = (int)$scoreinfocorp;
	if($scoreinfocorp2 == '0'){
		$o_ClienteBean->setClasificacionInfocorp(' ');
		$o_ClienteBean->setColorInfocorp(' ');
		$flaginfocorp = "N";
		
	}
	$o_ClienteBean->setIdCliente($id);
  	$o_ClienteBean->setFlagInfocorp($flaginfocorp);
  	$o_ClienteBean->setScoreInfocorp($scoreinfocorp);
  	//
  	//$clasificacion
  	//
  	
  	
  	
  	$o_ClienteBean->setFecActualizacionInfocorp(date("Y-m-d H:i:s"));
  	$o_ClienteBean->setUsrActualizacionInfocorp(myUser::getUser()->getUserId());
  	
  	setClasificacionInfocorp($id, $o_clasificacion->descripcion, $o_clasificacion->rangominimo, $o_clasificacion->rangomaximo, $scoreinfocorp,$o_clasificacion->color, $o_clasificacion->codigo,date("Y-m-d H:i:s"),myUser::getUser()->getUserId());
  	
  	$o_ClienteDP = new ClienteDP($o_ClienteBean);
  	$bResult = $o_ClienteDP->update();
    
    if( $bResult)
    {
        ?>
        <script>
        location.href = "<?php echo buildUrl('cli/datInfocorp', $s_Param) ?>";
        </script>
        <?php
    }
}

if( isset( $id ) )
{
    
    $o_ClienteBean = new ClienteBean();
    $o_ClienteBean->setIdCliente($id);
    $o_ClienteDP = new ClienteDP($o_ClienteBean);
    $a_o_Cliente = $o_ClienteDP->select();
    if(is_array($a_o_Cliente)){
    	foreach ($a_o_Cliente as $key => $o_ClienteBean){
    		$flaginfocorp = $o_ClienteBean->getFlagInfocorp();
    		$scoreinfocorp = $o_ClienteBean->getScoreInfocorp();
    		$clasificacioninfocorp = $o_ClienteBean->getClasificacionInfocorp();
    		$colorinfocorp = $o_ClienteBean->getColorInfocorp();
    		$fecactualizacioninfocorp = $o_ClienteBean->getFecActualizacionInfocorp();
    		$usractualizacioninfocorp = $o_ClienteBean->getUsrActualizacionInfocorp();
    	}
    }
}
?>

<script type="text/javascript">
validatePass = function()
{
	valid.onSubmit = false;
};

concatValueStr = function( s_Cadena )
{
    var cadenaFormulario = $('form1').serialize();
    cadenaFormulario = cadenaFormulario + "&" + s_Cadena;
    location.href = "<?php echo buildUrl('cli/datDoc', "") ?>?" + cadenaFormulario;
}

buscarLista = function()
{
    concatValueStr( '' );
}

limpiarForm = function()
{
    $( 'Tipo' ).value = "";
    $( 'Estado' ).value = "";
    $( 'txtFechaInicial' ).value = "";
    $( 'txtFechaFinal' ).value = "";
}
</script>
<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;Ficha del Cliente</I></span></td>
          <td align="right" valign="baseline">&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td valign="top">
 		<form id="form1" name="form1" method="POST">
			<input type="hidden" name="control" value="1">
			<input type="hidden" name="id" value="<?php echo $id ?>">
			<input type="hidden" name="TypeProcess" value=""/>
			<table hspace="20px" class="" width="96%">
	          <tr>
	            <td valign="top">
					<?php if(!$sinTabs){?>
					<table id="tabShowScan" cellpadding="0" cellspacing="0" class="" style="margin-top: 5px;">
						<tr>
						 
						  <?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('cli/edit', $s_Param) ?>';">Datos Personales</td>
						  <td class="mnuInactivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="8"></td>
						  <td><img src="/images/common/spacer.gif" width="8"></td>
						    <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('cli/datDoc', $s_Param) ?>';">Documentos</td>
	                  <td class="mnuInactivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="8"></td>
	                  <td><img src="/images/common/spacer.gif" width="8"></td>
						  <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('cli/datInfocorp', $s_Param) ?>';">Infocorp</td>
						  <td class="mnuActivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="8"></td>
						  
						  <td><img src="/images/common/spacer.gif" width="8"></td>
					  <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('cli/telefonos', $s_Param) ?>';">Telefonos</td>
					  <td class="mnuInactivoDer" type='maintTabguiaGeneral'><img src="/images/common/spacer.gif" width="8"></td>
				
						 
						  <?php } ?>
						</tr>
					</table>
					<?php }?>
					<table width="100%" cellspacing="2" cellpadding="2" border="0"   style="background: #E3E9E2" class="marco">
						<tr>
							<td nowrap="nowrap">
								   <table class="SubCabecera" width="100%" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<table width="100%">
												<tr>
												<td width="50%">
												<table >
													  <tr>
														<td><label class="label" for="Tipo">Infocorop</td>
														
														<td><select name="flaginfocorp" class="combo"><option value="F" <?php if($flaginfocorp=="F") echo "selected"?>>Falta</option><option <?php if($flaginfocorp=="S") echo "selected"?> value="S">Si</option><option <?php if($flaginfocorp=="N") echo "selected"?> value="N">No</option></select></td>
											
													  </tr>
													  <tr>
														<td width="15%"><label class="label">Score</label></td>  
														<td width="85%"><input type="text" class="text validate-number" name="scoreinfocorp" value="<?=$scoreinfocorp;?>" size="10" maxlength="3"></td>  
													   </tr>
														<tr>
														<td><label class="label">Descripci&oacute;n</label></td>  
														<td><label class="label"><label style="background:<?=$colorinfocorp;?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>&nbsp;<?php echo $clasificacioninfocorp;?></label></td>  
													   </tr>
													   <tr>
														<td><label class="label">Ultima Actualizacion</label></td>  
														<td><label class="label"><?php echo $fecactualizacioninfocorp;?></label></td>  
													   </tr>
													   <tr>
														<td><label class="label">Usuario Actualizacion</label></td>  
														<td><label class="label"><?php echo $usractualizacioninfocorp;?></label></td>  
													   </tr>
												</table>
												</td>
												<td width="50%">
													<table border="1" cellpadding="0" cellspacing="0" width="80%" class="grid">
															<th></th>
															<th>codigo</th>
															<th>descripcion</th>
															<th>rangominimo</th>
															<th>rangomaximo</th>
														<?php foreach ($a_clasificacion as $key => $clasificacion){?>
														<tr>
															<td style='background:<?php echo $clasificacion["color"]?>'>&nbsp;&nbsp;</td>
															<td align="center"><label class="label"><?php echo $clasificacion["codigo"]?></label></td>
															<td><?php echo $clasificacion["descripcion"]?></td>
															<td align="center"><?php echo $clasificacion["rangominimo"]?></td>
															<td  align="center"><?php echo $clasificacion["rangomaximo"]?></td>
														</tr>
														<?php }?>
													</table>
												</td>
												</tr>
											</table>
											
									</table>
									
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td height="0" width="100%">
				
				
										   <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="Anterior" onclick="location.href='<?php echo buildUrl('cli/edit', $s_Param) ?>'"/>
														<!--<input class="button" type="submit" value="Grabar" onclick="$('typeSubmit').value='ok';">-->
														<input class="button" type="submit" value="Grabar" onclick="$('typeSubmit').value='datInfocorp';">
														<!--<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('cli/datDocPe', $s_Param) ?>'"/>-->
														<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>
	
    </td>
  </tr>
</table>

