select codcliente,sum(importeeuros) as total from reciboscli where estado != 'Pagado' group by codcliente order by total DESC LIMIT 100 OFFSET 0;
select codcliente,sum(importe) as total from reciboscli where estado != 'Pagado' group by codcliente order by total DESC LIMIT 100 OFFSET 0;
public function euro_convert($precio, $coddivisa = NULL, $tasaconv = NULL)
private function clientes_deudores()
{
$tclist = array();
if( class_exists('recibo_cliente') )
{
$sql = "select codcliente, coddivisa, tasaconv, sum(importeeuros) as total from reciboscli"
. " where estado != 'Pagado' group by codcliente order by total DESC";
//$sql = "select codcliente,sum(importeeuros) as total from reciboscli"
// . " where estado != 'Pagado' group by codcliente order by total DESC";
}
else
{
$sql = "select codcliente,coddivisa, tasaconv,sum(totaleuros) as total from facturascli"
. " where pagada = false group by codcliente order by total DESC";
// $sql = "select codcliente,sum(totaleuros) as total from facturascli"
// . " where pagada = false group by codcliente order by total DESC";
}
$data = $this->db->select_limit($sql, 100, 0);
if($data)
{
foreach($data as $d)
{
$cliente = $this->cliente->get($d['codcliente']);
if($cliente)
{
if(!$cliente->debaja)
{
$deudas = $this->euro_convert( floatval($d['total']),$d['coddivisa'],$d['tasaconv'] );
//$deudas = $this->euro_convert( floatval($d['total']) );
$tclist[] = array($cliente, $deudas);
}
}
}
}
return $tclist;
}
class informe_clientes extends fs_controller
{
public $cliente;
public $opcion;
public $resultados;
public $clientes_deuda_total;
public function __construct()
private function clientes_deudores()
{
$tclist = array();
$this->clientes_deuda_total=0;
if( class_exists('recibo_cliente') )
{
$sql = "select codcliente, coddivisa, tasaconv, sum(importeeuros) as total from reciboscli"
. " where estado != 'Pagado' group by codcliente order by total DESC";
//$sql = "select codcliente,sum(importeeuros) as total from reciboscli"
// . " where estado != 'Pagado' group by codcliente order by total DESC";
}
else
{
$sql = "select codcliente,coddivisa, tasaconv,sum(totaleuros) as total from facturascli"
. " where pagada = false group by codcliente order by total DESC";
// $sql = "select codcliente,sum(totaleuros) as total from facturascli"
// . " where pagada = false group by codcliente order by total DESC";
}
$data = $this->db->select($sql);
if($data)
{
foreach($data as $d)
{
$cliente = $this->cliente->get($d['codcliente']);
if($cliente)
{
if(!$cliente->debaja)
{
$deudas = $this->euro_convert( floatval($d['total']),$d['coddivisa'],$d['tasaconv'] );
$this->clientes_deuda_total += $deudas;
//$deudas = $this->euro_convert( floatval($d['total']) );
$tclist[] = array($cliente, $deudas);
}
}
}
}
return $tclist;
}
<tr class="warning">
<td colspan="6">Sin resultados.</td>
</tr>
{/loop}
<tr class="warning">
<td colspan="6" class="text-right">Total: {$fsc->show_precio($fsc->clientes_deuda_total)}</td>
</tr>