mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido generar factura desde pedido
This commit is contained in:
@ -76,6 +76,36 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function obtenerDatosForFactura($pedido_id = -1){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("
|
||||
t3.cliente_id, t4.nombre as cliente_nombre, t4.cif as cliente_cif, t4.direccion as cliente_direccion,
|
||||
t5.nombre as cliente_pais, t4.cp as cliente_cp, t4.ciudad as cliente_ciudad, t6.nombre as cliente_provincia
|
||||
"
|
||||
)
|
||||
->join("pedidos_linea t2", "t2.pedido_id = t1.id", "left")
|
||||
->join("presupuestos t3", "t2.presupuesto_id = t3.id", "left")
|
||||
->join("clientes t4", "t4.id = t3.cliente_id", "left")
|
||||
->join("lg_paises t5", "t5.id = t4.pais_id", "left")
|
||||
->join("lg_provincias t6", "t6.id = t4.provincia_id", "left");
|
||||
|
||||
$builder->where("t1.id", $pedido_id);
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
public function addFacturaPedidoLinea($pedido_id, $factura_id, $cantidad)
|
||||
{
|
||||
return $this->db
|
||||
->table("facturas_pedidos_lineas")
|
||||
->insert([
|
||||
"factura_id" => $factura_id,
|
||||
"pedido_id" => $pedido_id,
|
||||
"cantidad" => $cantidad
|
||||
]);
|
||||
}
|
||||
|
||||
public function obtenerLineasPedido($pedido_id)
|
||||
{
|
||||
$builder = $this->db
|
||||
@ -91,6 +121,7 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
foreach ($builder->get()->getResultObject() as $row) {
|
||||
array_push($lineasPresupuesto, $model_presupuesto->generarLineaPedido($row->presupuesto_id)[0]);
|
||||
}
|
||||
$builder->groupBy("t1.id");
|
||||
|
||||
return $lineasPresupuesto;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user