|
|
@@ -660,7 +660,7 @@ class CorrectiveMaintenanceController extends Controller
|
|
|
}
|
|
|
|
|
|
$order = DB::table('S002V01TOTCO')
|
|
|
- ->select(['OTCO_HIES', 'OTCO_RHUT'])
|
|
|
+ ->select(['OTCO_HIES', 'OTCO_RHUT', 'OTCO_ANCO'])
|
|
|
->where([
|
|
|
['OTCO_IDOT', '=', $idOrder],
|
|
|
['OTCO_NULI', '=', $line]
|
|
|
@@ -780,12 +780,22 @@ class CorrectiveMaintenanceController extends Controller
|
|
|
|
|
|
$this->functionsController->registerLog($actions, $idUser, $nowStr, $idac, $line);
|
|
|
|
|
|
+ // Verificar si ya existe análisis previo
|
|
|
+ $tieneAnalisisPrevio = !is_null($order->OTCO_ANCO) && $order->OTCO_ANCO !== '';
|
|
|
+ $analisisPrevio = null;
|
|
|
+
|
|
|
+ if ($tieneAnalisisPrevio) {
|
|
|
+ $analisisPrevio = json_decode($order->OTCO_ANCO, true);
|
|
|
+ }
|
|
|
+
|
|
|
return $this->responseController->makeResponse(false, 'EXITO.', [
|
|
|
'USUARIOS' => $usuariosParticipantes,
|
|
|
'HERRAMIENTAS' => $herramientas,
|
|
|
'REFACCIONES' => $refacciones,
|
|
|
'SUBTOTAL_HERRAMIENTAS' => $subtotalHerramientasArray,
|
|
|
- 'SUBTOTAL_REFACCIONES' => $subtotalRefaccionesArray
|
|
|
+ 'SUBTOTAL_REFACCIONES' => $subtotalRefaccionesArray,
|
|
|
+ 'TIENE_ANALISIS_PREVIO' => $tieneAnalisisPrevio,
|
|
|
+ 'ANALISIS_PREVIO' => $analisisPrevio
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
@@ -837,15 +847,21 @@ class CorrectiveMaintenanceController extends Controller
|
|
|
return $this->responseController->makeResponse(true, 'El ID de la orden no fue encriptado correctamente.', [], 400);
|
|
|
}
|
|
|
|
|
|
- $order = DB::table('S002V01TOTCO')->where([
|
|
|
- ['OTCO_IDOT', '=', $idOrder],
|
|
|
- ['OTCO_NULI', '=', $form['linea']]
|
|
|
- ])->first();
|
|
|
+ $order = DB::table('S002V01TOTCO')
|
|
|
+ ->select(['OTCO_IDOT', 'OTCO_ESOR'])
|
|
|
+ ->where([
|
|
|
+ ['OTCO_IDOT', '=', $idOrder],
|
|
|
+ ['OTCO_NULI', '=', $form['linea']]
|
|
|
+ ])->first();
|
|
|
|
|
|
if (is_null($order)) {
|
|
|
return $this->responseController->makeResponse(true, 'La orden no está registrada.', [], 404);
|
|
|
}
|
|
|
|
|
|
+ if ($order->OTCO_ESOR !== 'CP') {
|
|
|
+ return $this->responseController->makeResponse(true, 'Solo se puede registrar análisis de costos en órdenes con estado "Cerrado pendiente".', [], 400);
|
|
|
+ }
|
|
|
+
|
|
|
$analisisCostos = [
|
|
|
'FECHA' => $this->functionsController->now()->toDateTimeString(),
|
|
|
'USUARIO' => $idUser,
|