|
|
@@ -80,9 +80,12 @@ class OrderController extends Controller {
|
|
|
|
|
|
public function createOrder(Request $request){
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
- 'NUMERO_LINEA' => 'required|string',
|
|
|
'NUMERO_SOLICITUD' => 'required|string',
|
|
|
- 'DESPACHO' => 'required|integer',
|
|
|
+ 'DESPACHO' => 'required|string',
|
|
|
+ 'PROPOSITO' => 'required|string',
|
|
|
+ 'ID_MANT_PREV' => 'nullable|string',
|
|
|
+ 'ID_MANT_CORR' => 'nullable|string',
|
|
|
+ 'NUMERO_LINEA' => 'required|string',
|
|
|
'USUARIO' => 'required|string',
|
|
|
]);
|
|
|
|
|
|
@@ -97,12 +100,12 @@ class OrderController extends Controller {
|
|
|
DB::beginTransaction();
|
|
|
$requestData = $request->all();
|
|
|
|
|
|
- try {
|
|
|
- $user = $this->encController->decrypt($requestData['USUARIO']);
|
|
|
- } catch (\Throwable $th) {
|
|
|
+ $arrResponseCheckUser = $this->resourcesController->checkUserEnc($requestData['USUARIO'], $requestData['NUMERO_LINEA']);
|
|
|
+ if ($arrResponseCheckUser['error']) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ORDER_REG001: Ocurrió un error al obtener el usuario.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_WAREHOUSE_GETBY000:'.$arrResponseCheckUser['msg'], [], 401);
|
|
|
}
|
|
|
+ $user = $arrResponseCheckUser['response'];
|
|
|
|
|
|
$now = $this->functionsController->now();
|
|
|
$currentDate = $now->toDateTimeString();
|
|
|
@@ -124,6 +127,14 @@ class OrderController extends Controller {
|
|
|
DB::rollBack();
|
|
|
return $this->responseController->makeResponse(true, "ERR_ORDER_REG003: No se pudo registrar la orden de compra.", [], 401);
|
|
|
}
|
|
|
+
|
|
|
+ $idMantPrev = null;
|
|
|
+ $idMantCorr = null;
|
|
|
+ if ($requestData['PROPOSITO'] === 'MANT-PREV' && !is_null($requestData['ID_MANT_PREV'])) {
|
|
|
+ $idMantPrev = $requestData['ID_MANT_PREV'];
|
|
|
+ } else if ($requestData['PROPOSITO'] === 'MANT-CORR' && !is_null($requestData['ID_MANT_CORR'])) {
|
|
|
+ $idMantCorr = $requestData['ID_MANT_CORR'];
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
$validateUpdate = DB::table('S002V01TLINE')
|
|
|
@@ -131,6 +142,8 @@ class OrderController extends Controller {
|
|
|
->where('LINE_NULI', '=', $requestData['NUMERO_LINEA'])
|
|
|
->update([
|
|
|
'LINE_ESTA' => 'En OC',
|
|
|
+ 'LINE_OTPR' => $idMantPrev,
|
|
|
+ 'LINE_OTCO' => $idMantCorr,
|
|
|
'LINE_USMO' => $user,
|
|
|
'LINE_FEMO' => $currentDate,
|
|
|
'LINE_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
|