mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into feat/maquinas-corte-ot
This commit is contained in:
@ -2077,7 +2077,10 @@ class PresupuestoService extends BaseService
|
||||
|
||||
$merma = 0;
|
||||
|
||||
if ($tirada > $POD) {
|
||||
if ($tirada == 0) {
|
||||
$merma = 0;
|
||||
}
|
||||
else if ($tirada > $POD) {
|
||||
$merma = $tirada * 0.1;
|
||||
} else {
|
||||
$merma_lineas = [];
|
||||
@ -2105,4 +2108,93 @@ class PresupuestoService extends BaseService
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function duplicarPresupuesto($id = null, $is_reimpresion = false, $copy_files = false)
|
||||
{
|
||||
try {
|
||||
|
||||
$modelPresupuesto = model('App\Models\Presupuestos\PresupuestoModel');
|
||||
$presupuesto = $modelPresupuesto->find($id);
|
||||
if (!$presupuesto || $id == null) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => lang('Presupuestos.presupuestoNotFound'),
|
||||
];
|
||||
}
|
||||
$presupuesto->titulo = $presupuesto->titulo . ' - ' . lang('Presupuestos.duplicado');
|
||||
$presupuesto->is_duplicado = 1;
|
||||
$presupuesto->estado_id = 1;
|
||||
if($is_reimpresion && boolval($copy_files)){
|
||||
$presupuesto->inc_rei = "reimpresion";
|
||||
$modelPedidoLinea = model('App\Models\Pedidos\PedidoLineaModel');
|
||||
$pedido_linea = $modelPedidoLinea->where('presupuesto_id', $id)->first();
|
||||
if($pedido_linea){
|
||||
$text = "REIMPRESION [" . date('Y-m-d H:i:s') . "] - PEDIDO: " . $pedido_linea->pedido_id .
|
||||
"\n================================================\n";
|
||||
$presupuesto->comentarios_safekat = $presupuesto->comentarios_safekat . $text;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$presupuesto->inc_rei = null;
|
||||
}
|
||||
$new_id = $modelPresupuesto->insert($presupuesto);
|
||||
|
||||
$presupuestoAcabadosModel = model('App\Models\Presupuestos\PresupuestoAcabadosModel');
|
||||
foreach ($presupuestoAcabadosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $acabado) {
|
||||
$acabado->presupuesto_id = $new_id;
|
||||
$presupuestoAcabadosModel->insert($acabado);
|
||||
}
|
||||
|
||||
$presupuestoEncuadernacionesModel = model('App\Models\Presupuestos\PresupuestoEncuadernacionesModel');
|
||||
foreach ($presupuestoEncuadernacionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $encuadernacion) {
|
||||
$encuadernacion->presupuesto_id = $new_id;
|
||||
$presupuestoEncuadernacionesModel->insert($encuadernacion);
|
||||
}
|
||||
|
||||
$presupuestoManipuladosModel = model('App\Models\Presupuestos\PresupuestoManipuladosModel');
|
||||
foreach ($presupuestoManipuladosModel->where('presupuesto_id', $presupuesto->id)->findAll() as $manipulado) {
|
||||
$manipulado->presupuesto_id = $new_id;
|
||||
$presupuestoManipuladosModel->insert($manipulado);
|
||||
}
|
||||
|
||||
$presupuestoPreimpresionesModel = model('App\Models\Presupuestos\PresupuestoPreimpresionesModel');
|
||||
foreach ($presupuestoPreimpresionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $preimpresion) {
|
||||
$preimpresion->presupuesto_id = $new_id;
|
||||
$presupuestoPreimpresionesModel->insert($preimpresion);
|
||||
}
|
||||
|
||||
$presupuestoServiciosExtraModel = model('App\Models\Presupuestos\PresupuestoServiciosExtraModel');
|
||||
foreach ($presupuestoServiciosExtraModel->where('presupuesto_id', $presupuesto->id)->findAll() as $servicioExtra) {
|
||||
$servicioExtra->presupuesto_id = $new_id;
|
||||
$presupuestoServiciosExtraModel->insert($servicioExtra);
|
||||
}
|
||||
|
||||
$presupuestoDireccionesModel = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
foreach ($presupuestoDireccionesModel->where('presupuesto_id', $presupuesto->id)->findAll() as $direccion) {
|
||||
$direccion->presupuesto_id = $new_id;
|
||||
$presupuestoDireccionesModel->insert($direccion);
|
||||
}
|
||||
|
||||
$presupuestoLineaModel = model('App\Models\Presupuestos\PresupuestoLineaModel');
|
||||
$presupuestoLineaModel->duplicateLineasPresupuesto($presupuesto->id, $new_id);
|
||||
|
||||
|
||||
if (boolval($copy_files)== true) {
|
||||
$presupuestoFilesModel = model('App\Models\Presupuestos\PresupuestoFicheroModel');
|
||||
$presupuestoFilesModel->copyFiles($presupuesto->id, $new_id);
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'id' => $new_id,
|
||||
'message' => lang('Presupuestos.presupuestoGenerado'),
|
||||
];
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -924,6 +924,29 @@ class ProductionService extends BaseService
|
||||
|
||||
|
||||
|
||||
return $q;
|
||||
}
|
||||
public function maquinaPlanaDatatableQuery()
|
||||
{
|
||||
$q = $this->otModel->builder()->select([
|
||||
"lg_maquinas.nombre as maquinaNombre",
|
||||
"lg_maquinas.id as maquinaId",
|
||||
"COUNT(orden_trabajo_tareas.id) as tareasCount",
|
||||
"presupuesto_linea.pliegos_pedido as pliegosPedido",
|
||||
"SUM(ordenes_trabajo.total_tirada) as totalTirada",
|
||||
"SUM(orden_trabajo_tareas.tiempo_real) as tiempoReal"
|
||||
])
|
||||
->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left")
|
||||
->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left")
|
||||
->join("presupuestos", "presupuestos.id = presupuesto_linea.presupuesto_id", "right")
|
||||
->join('lg_maquinas',"lg_maquinas.id = orden_trabajo_tareas.maquina_id","left")
|
||||
->where("orden_trabajo_tareas.deleted_at", null)
|
||||
->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL, FALSE)
|
||||
->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA)
|
||||
->groupBy('lg_maquinas.id');
|
||||
|
||||
|
||||
|
||||
return $q;
|
||||
}
|
||||
/**
|
||||
@ -1334,13 +1357,14 @@ class ProductionService extends BaseService
|
||||
->whereIn("presupuesto_linea.tipo", $this->TIPOS_ROTATIVA)
|
||||
->where('lg_maquinas.is_rotativa', true)
|
||||
->where("orden_trabajo_tareas.deleted_at", null)
|
||||
->orderBy("orden_trabajo_tareas.orden", "ASC");
|
||||
->orderBy("orden_trabajo_tareas.orden", "ASC")
|
||||
->groupBy('lg_maquinas.id');
|
||||
if ($q) {
|
||||
$query->like('lg_maquinas.nombre', $q);
|
||||
}
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
public function querySelectMaquinaPlanningPlana($q)
|
||||
public function querySelectMaquinaPlanningPlana($q,?string $padreId)
|
||||
{
|
||||
$query = $this->otModel->builder()->select([
|
||||
"orden_trabajo_tareas.maquina_id as id",
|
||||
@ -1352,10 +1376,14 @@ class ProductionService extends BaseService
|
||||
->whereIn("presupuesto_linea.tipo", $this->TIPOS_PLANA)
|
||||
->where('lg_maquinas.is_rotativa', false)
|
||||
->where("orden_trabajo_tareas.deleted_at", null)
|
||||
->orderBy("orden_trabajo_tareas.orden", "ASC");
|
||||
->orderBy("orden_trabajo_tareas.orden", "ASC")
|
||||
->groupBy('lg_maquinas.id');
|
||||
if ($q) {
|
||||
$query->like('lg_maquinas.nombre', $q);
|
||||
}
|
||||
if($padreId){
|
||||
$query->where('lg_maquinas.padre_id',$padreId);
|
||||
}
|
||||
return $query->get()->getResultArray();
|
||||
}
|
||||
public function querySelectMaquinaPadrePlanningPlana($q)
|
||||
|
||||
Reference in New Issue
Block a user