<?php
/*
TABELA DE PAGAMENTO PARCELADO BASEADO NO MODULO DO VALMY BY MARCELO_73 MARCELO@APOPULAR.COM.BR
SÃO JOSÉ DOS CAMPOS, 10 DE ABRIL DE 2008, BRASIL
1 - MOSTRA O VALOR PARCELADO EM ATE 12 PARCELAS
2 - MOSTRA TODAS AS OPÇÕES DE PAGAMENTO SEJAM ELAS Á VISTA OU A PRAZO COM JUROS
3 - MOSTRA PARCELAS DE CHEQUE SEM JUROS EM ATE 2 VEZES
2 - MOSTRA SOMENTE ATE O VALOR DA PARCELA MINIMA DEFINIDA (PADRÃO DO PAGSEGURO R$10,00)
3 - ALTERAÇÃO DO LAYOUT
*/
##############################################################################
##############################################################################
##############################OTIMIZADO PELA BYTESDESIGN.COM########################
######################### UTILIZANDO PARTE DO CÓDIGO DO KOMMERCE ######################
################################# CONTEÚDO OPENSOURCE ###########################
##############################################################################
function splitCredit($totalValue){
///////////////////////////////////////////
// Variáveis que devem ser alteradas ///
//---------------------------------------
$minvalor = 10; // VALOR MINIMO DE CADA PARCELA
$desconto = 0;//Valor da percentagem de Desconto atribuída ao produto
$parcelaqtminimacc = '12'; ///QUANTIDADE MÁXIMA DE PARCELAS
/////////////////////////////////////////
$splits = (int) ($totalValue/$minValue);
$valor = ( $totalValue / ($i+1) );
$totaldesconto = $valor - (($desconto/100)*$valor);
$minSemJuros = 0;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$table = '
<table width="270" style="border: 1px dotted #CCCCCC;" cellpadding="0" cellspacing="0"><tr><td colspan="3" class="headtop">FORMAS DE PAGAMENTO</td></tr><tr><td class="head">Nºde<BR>parcelas</td><td class="head">Valor da <BR>parcela</td><td class="head">Valor <BR>Total</td></tr>';
for($i = 0; $i < $splits; $i++){
if($i>$parcelaqtminimacc - 1){break;}
$i % 2 == 0 ? $class = "res1" : $class = "res2";
if($i=='1'){
$parcela = $valor - (($desconto/100)*$valor);
$table .= '<tr>
<td class="res1">Deposito Bradesco</td>
<td class="res1">R$ '. number_format($totalValue+$taxa0 , 2 , "," , ".") .'</td>
<td class="res1">R$ '. number_format($totalValue+$taxa0*1 , 2 , "," , ".") .'</td>
</tr>';
$parcela = $valor - (($desconto/100)*$valor);
$table .= '<tr>
<td class="res2">Deposito HSBC</td>
<td class="res2">R$ '. number_format($totalValue+$taxa0 , 2 , "," , ".") .'</td>
<td class="res2">R$ '. number_format($totalValue+$taxa0*1 , 2 , "," , ".") .'</td>
</tr>';
$parcela = $valor - (($desconto/100)*$valor);
$table .= '<tr>
<td class="res1">Deposito Nossa Caixa</td>
<td class="res1">R$ '. number_format($totalValue+$taxa0 , 2 , "," , ".") .'</td>
<td class="res1">R$ '. number_format($totalValue+$taxa0*1 , 2 , "," , ".") .'</td>
</tr>';
$parcela = $valor - (($desconto/100)*$valor);
$table .= '<tr>
<td class="res2">Boleto Bancário</td>
<td class="res2">R$ '. number_format($totalValue+$taxa1 , 2 , "," , ".") .'</td>
<td class="res2">R$ '. number_format($totalValue+$taxa1*1 , 2 , "," , ".") .'</td>
</tr>';
########################## CHEQUE INICIO #######################
$parcela = $valor - (($desconto/100)*$valor);
$table .= '<tr>
<td class="res1">2x Cheque(0,30 dias)</td>
<td class="res1">R$ '. number_format($totalValue/2 , 2 , "," , ".") .'</td>
<td class="res1">R$ '. number_format($totalValue/2*2 , 2 , "," , ".") .'</td>
</tr>';
$parcela = $valor - (($desconto/100)*$valor);
$table .= '<tr>
<td class="res2">3x Cheque(0,30,60 dias)</td>
<td class="res2">R$ '. number_format($totalValue/3 , 2 , "," , ".") .'</td>
<td class="res2">R$ '. number_format($totalValue/3*3 , 2 , "," , ".") .'</td>
</tr>';
########################## CHEQUE FIM #########################
}
if($i <= $minSemJuroscc){
$table .= '<tr>
<td class="'.$class.'"><b>'. ($i+1) . 'x Sem Juros</b></td>
<td class="'.$class.'">de <b>R$ '. number_format($valor/($i+1) , 2 , "," , ".") . '</b></td>
<td class="'.$class.'"> R$ '. number_format($valor, 2 , "," , ".").' </td>
</tr>';
}else{
////////////////////////////ATUALIZADO POR BYTESDESIGN.COM//////////////
if($i+1=='2'){$taxa = 0.5201;}// MULTIPLICADOR DA 2ª PARCELA
if($i+1=='3'){$taxa = 0.35365;} // MULTIPLICADOR DA 3ª PARCELA
if($i+1=='4'){$taxa = 0.2705;} // MULTIPLICADOR DA 4ª PARCELA
if($i+1=='5'){$taxa = 0.2207;} // MULTIPLICADOR DA 5ª PARCELA
if($i+1=='6'){$taxa = 0.1876;} // MULTIPLICADOR DA 6ª PARCELA
if($i+1=='7'){$taxa = 0.1640;} // MULTIPLICADOR DA 7ª PARCELA
if($i+1=='8'){$taxa = 0.1463;} // MULTIPLICADOR DA 8ª PARCELA
if($i+1=='9'){$taxa = 0.132665;} // MULTIPLICADOR DA 9ª PARCELA
if($i+1=='10'){$taxa = 0.1218;} // MULTIPLICADOR DA 10ª PARCELA
if($i+1=='11'){$taxa = 0.112908;} // MULTIPLICADOR DA 10ª PARCELA
if($i+1=='12'){$taxa = 0.105565;} // MULTIPLICADOR DA 12ª PARCELA
if (number_format($totalValue*$taxa , 2 , "," , ".") > $minvalor){
$valor = ( $totalValue / ($i+1) );
$table .= '<tr>
<td class="res1"> '. ($i+1) . 'x com juros*</td>
<td class="res1">R$ '. number_format($totalValue*$taxa , 2 , "," , ".") .'</td>
<td class="res1">R$ '. number_format($totalValue*$taxa*($i+1) , 2 , "," , ".") .'</td>
</tr>';
}
}
}
$table .= "</table>";
return $table;
}
///////////////////EXTRAS////////////////
//////CALCULO CORRETO DOS JUROS AO MÊS
/*
EX:
$taxa= '5.9';
$caltaxa = $totalValue/1000*($taxa) ;
$parcelaz = pow((1+($juroscartao/100)),($i+1)) - 1;
$parcelaw = pow((1+($juroscartao/100)),($i+1)) * ($juroscartao/100);
$parcela = $totalValue/ ($parcelaz / $parcelaw );
$table .= '<tr>
<td class="'.$class.'"> '. ($i+1) . 'x com juros*</td>
<td class="'.$class.'"> de R$ '. number_format($parcela +$caltaxa , 2 , "," , ".") . ' </td>
<td class="'.$class.'"> <b>R$ '. number_format(($parcela+$caltaxa)*($i+1) , 2 , "," , ".").'</b> </td>
</tr>';
*/
////////////////////////FIM DA CONTRIBUIÇÃO DA BYTESDESIGN.COM
////////////////////////ESPERO QUE TENHAM GOSTADO DA OTIMIZAÇÃO
////////////////////////VEJAM EXEMPLO EM HTTP://DEBUG.NETFARMA.NET
?>
<table width="250" style="border: 0px dotted #ff0000;" cellpadding="0" cellspacing="0">
<tr><td class="res4">Taxa de 1,99% ao mês no cartão de crédito</td>
</tr> <td align="center"> </td>
<style>
.headtop{font-family:'Verdana';font-size:10px;background-color:#2C72DA;font-weight:bold;text-align:center;color:#ffffff;border:1px solid #ffffff;}
.head{font-family:'Verdana';font-size:10px;background-color:#F1F1F1;font-weight:bold;text-align:center;color:#333333;border:1px solid #ffffff;}
.head2{font-family:'Verdana';font-size:10px;background-color:#c9c8b4;font-weight:bold;text-align:center;color:#333333;border:1px solid #ffffff;}
.res1{font-family:'Verdana';font-size:10px;background-color:#ffffff;text-align:center;color:#000000;}
.res2{font-family:'Verdana';font-size:10px;background-color:#f1f1f1;text-align:center;color:#000000;border:1px solid #ffffff;}
.res4{font-family:'Verdana';font-size:9px;background-color:#ffffff;font-weight:bold;text-align:center;color:#666666;}
</style>