mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido facturas. faltan filtros pedidos
This commit is contained in:
@ -145,6 +145,40 @@ class FacturaModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getSumatoriosFacturacionCliente($cliente_id = -1){
|
||||
|
||||
if($cliente_id == -1){
|
||||
return [
|
||||
'total_facturacion' => 0,
|
||||
'total_pendiente' => 0
|
||||
];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$data = $this->db->table('facturas f')
|
||||
->select('sum(f.total) as total')
|
||||
->where('f.cliente_id', $cliente_id)
|
||||
->where('f.deleted_at IS NULL')
|
||||
->where('f.estado', 'validada')
|
||||
->get()
|
||||
->getResultObject();
|
||||
$result['total_facturacion'] =
|
||||
round(floatval(($data && $data[0]->total != null) ? $data[0]->total : 0), 2);
|
||||
|
||||
$data = $this->db->table('facturas f')
|
||||
->select('sum(f.pendiente) as pendiente')
|
||||
->where('f.cliente_id', $cliente_id)
|
||||
->where('f.deleted_at IS NULL')
|
||||
->where('f.estado', 'validada')
|
||||
->where('f.estado_pago', 'pendiente')
|
||||
->get()
|
||||
->getResultObject();
|
||||
$result['total_pendiente'] =
|
||||
round(floatval(($data && $data[0]->pendiente != null) ? $data[0]->pendiente : 0), 2);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
|
||||
@ -232,6 +232,21 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
return $presupuesto_ficheros;
|
||||
}
|
||||
|
||||
|
||||
public function getPedidosClienteForm($cliente_id = -1){
|
||||
$builder = $this->db
|
||||
->table($this->table . " p")
|
||||
->select('p.id, p.created_at as fecha, p.fecha_entrega_real as fecha_entrega,
|
||||
pr.paginas as paginas, p.total_tirada, p.total_precio, p.estado')
|
||||
->join('pedidos_linea pl', 'pl.pedido_id = p.id', 'left')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id', 'left')
|
||||
//->where('pr.deleted_at IS NULL')
|
||||
->where('pr.cliente_id', $cliente_id)
|
||||
->orderBy('p.created_at', 'DESC')
|
||||
->groupBy('p.id');
|
||||
return $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crea una orden de trabajo asociada al pedido
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user