<%args>
$user=>undef
$extra_info=>undef
</%args>
<%init>
return undef unless $user;

my ($cod_cliente) = $m->comp("/_shared/procs/users/login/user_getclient.m",  user=>$user);
return undef unless $cod_cliente;

my $dbh = $m->comp("/_shared/procs/utils/dbi_connect.m", database=>'guianet');
my ($credits,$used_credits) = $dbh->selectrow_array("select sum(creditos_disponiveis), sum(creditos_utilizados) from tdownloads_credits_new where cod_cliente='$cod_cliente'");

if ($extra_info){
	my ($use_count) = $dbh->selectrow_array("select count(*) from tdownloads_history where username='$user'");
	my $first_time = $use_count == 0;
	return ($credits, $used_credits, $first_time);
}else{
	return ($credits,$used_credits);
}
</%init>
