Merge branch 'main' into feat/update-ot-flow

This commit is contained in:
amazuecos
2025-05-22 18:34:08 +02:00
21 changed files with 1036 additions and 259 deletions

View File

@ -35,7 +35,7 @@ class EnvioLineaModel extends Model
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id, t1.pedido_id as pedido, t3.id as presupuesto,
"t1.id, t1.pedido_id as pedido, t3.id as presupuesto, t4.id as ordenTrabajo,
t3.titulo as titulo, t1.unidades_envio as unidadesEnvio, t1.unidades_envio as unidadesEnvioRaw,
t1.unidades_total as unidadesTotal, t2.tipo_envio as tipo_envio,
IFNULL((
@ -59,6 +59,7 @@ class EnvioLineaModel extends Model
);
$builder->join("envios t2", "t1.envio_id = t2.id", "left");
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
$builder->join("ordenes_trabajo t4", "t1.pedido_id = t4.pedido_id", "left");
$builder->where("t1.envio_id", $envio_id);

View File

@ -143,4 +143,25 @@ class OrdenTrabajoModel extends Model
->groupBy('orden_trabajo_tareas.id');
return $query;
}
public function queryProximosEnvios()
{
$query = $this->builder()
->select([
'ordenes_trabajo.id as ot',
'orden_trabajo_dates.encuadernacion_at as fechaEncuadernado',
])
->join('pedidos', 'pedidos.id = ordenes_trabajo.pedido_id', 'left')
->join('pedidos_linea', 'pedidos.id = pedidos_linea.pedido_id', 'left')
->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left')
->join('presupuesto_direcciones', 'presupuestos.id = presupuesto_direcciones.presupuesto_id', 'left')
->join('orden_trabajo_dates', 'orden_trabajo_dates.orden_trabajo_id = ordenes_trabajo.id', 'left')
->where('ordenes_trabajo.deleted_at', null)
->where('orden_trabajo_dates.encuadernacion_at !=', null)
//->where('orden_trabajo_dates.fecha_encuadernado_at >=', 0)
//->where('ordenes_trabajo.fecha_entrega_warning >=', date("Y-m-d H:i:s"))
->groupBy('ordenes_trabajo.id');
return $query;
}
}

View File

@ -25,7 +25,7 @@ class ImportadorModel extends \App\Models\BaseModel
$builder = $db->table('pedido_libro');
$builder->select('id as id, CONCAT(id, " - ", titulo) as name');
$builder->where('customer_id', $clienteId);
$builder->whereIn('estado', ['finalizado', 'validado']);
$builder->whereIn('estado', ['finalizado', 'validado', 'presupuesto']);
$builder->where('deleted_at', NULL);
$builder->orderBy('updated_at', 'DESC');