<?php require_once('../Connections/paivaconex.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_clientes = "-1";
if (isset($_POST['id'])) {
  $colname_clientes = $_POST['id'];
}
mysql_select_db($database_paivaconex, $paivaconex);
$query_clientes = sprintf("SELECT * FROM mfin_clientes WHERE Id = %s", GetSQLValueString($colname_clientes, "int"));
$clientes = mysql_query($query_clientes, $paivaconex) or die(mysql_error());
$row_clientes = mysql_fetch_assoc($clientes);
$totalRows_clientes = mysql_num_rows($clientes);

?>

<style>
#linha_pai{
    height: 12px;
    border: 0;
    box-shadow: inset 0 12px 12px -12px rgba(0, 0, 0, 0.5);
}

</style>
<?php $identificador = rand(); ?>

<div class="0" id="<?php echo $identificador; ?>">
<table id="linha_<?php echo $_POST['contador'];?>" border="0" align="center" class="descricao_contar" bordercolor="#000000">
<tr>
  <td width="60" align="right" rowspan="2" bordercolor="#FFFFFF"><?php echo $_POST['contador'];?> </br><input type="button" name="remover" id="remover" value="X" /></td>
    
  <td bordercolor="#FFFFFF" ><label for="cli_nome[]"></label>
    <input name="cli_nome[]" type="text" id="cli_nome[]" value="<?php echo htmlentities($row_clientes['NomeFantasia'], ENT_COMPAT, 'iso-8859-1'); ?>" readonly="readonly">   </td>
    
  <td bordercolor="#FFFFFF" ><label for="cli_valor[]"></label>
    <input name="cli_valor[]" type="text" class="valor" id="cli_valor" value="<?php echo number_format($_POST['valor'],2,',','.'); ?>">  
    </td>
    
  <td bordercolor="#FFFFFF" >
    <input name="juros_repass[]" type="text" class="juros_repass" id="juros_repass2" value="<?php echo number_format($_POST['juros_repasse'],2,',','.'); ?>" /></td>
  <td bordercolor="#FFFFFF" >
    <input name="honorarios2[]" type="text" class="honorarios2" id="honorarios2" value="<?php echo number_format($_POST['honorarios22'],2,',','.'); ?>" /></td>
  <td bordercolor="#FFFFFF" >
    <input name="outros[]" type="text" class="desconto" id="repass2" value="<?php echo number_format($_POST['outross'],2,',','.'); ?>" /></td>
   <input name="dtpagamento[]" type="hidden" class="dtpagamento" id="dtpagamento" value="" /></td>
    
  
    
    
    <input type="hidden" name="cli_id[]" id="cli_id[]" value="<?php echo $row_clientes['Id']; ?>">
	<input type="hidden" name="identificador[]" id="identificador" value="<?php echo $identificador; ?>">
  </tr>
	<tr>
    
    <td bordercolor="#FFFFFF"><input name="outros2[]" type="text" class="desconto" id="repass" value="<?php echo number_format($_POST['outros2s'],2,',','.'); ?>" /></td>
    <td bordercolor="#FFFFFF" >
    <input name="honorarios[]" type="text" class="desconto" id="repass3" value="<?php echo number_format($_POST['honorarioss'],2,',','.'); ?>" /></td>
    <td bordercolor="#FFFFFF" ><input name="repass[]" type="text" class="descon" id="repass4" value="<?php echo number_format($_POST['repasse'],2,',','.'); ?>" /></td>
    <td align="center" width="100" bordercolor="#FFFFFF" >
    =
    </td>
    <td bordercolor="#FFFFFF">
    <input name="result[]" type="text" class="juros_repass" id="juros_repass" value="<?php echo number_format($_POST['resultado'],2,',','.'); ?>" readonly="readonly">  
    </td>
</tr>
	<tr>
		<td colspan="6" align="center">   <input type="button" name="adicionar_herdeiro" id="adicionar_herdeiro" value="Adicionar herdeiro" /> </td>
	</tr>

</table>
<hr id="linha_pai">
</div>

<?php
mysql_free_result($clientes);
?>
