|
|
@@ -747,7 +747,7 @@ class ArtitleController extends Controller {
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrArtitle);
|
|
|
}
|
|
|
|
|
|
- public function registerArtitles(Request $request) {
|
|
|
+ public function registerArtitlesOld(Request $request) {
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'CODIGO' => 'required|string',
|
|
|
'ARTICULO' => 'required|string',
|
|
|
@@ -755,7 +755,7 @@ class ArtitleController extends Controller {
|
|
|
'SUBFAMILIA' => 'required|string',
|
|
|
'INFORMATION' => 'required|array',
|
|
|
'USUARIO' => 'required|string',
|
|
|
- 'NUMERO_LINEA' => 'required|string',
|
|
|
+ 'NUMERO_LINEA' => 'required|integer',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
@@ -924,6 +924,165 @@ class ArtitleController extends Controller {
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
|
|
|
}
|
|
|
|
|
|
+ public function registerArticle (Request $request) {
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'CODIGO' => 'required|string',
|
|
|
+ 'ARTICULO' => 'required|string',
|
|
|
+ 'FAMILIA' => 'required|string',
|
|
|
+ 'SUBFAMILIA' => 'required|string',
|
|
|
+ 'DESCRIPCION_ARTICULO' => 'required|array',
|
|
|
+ 'USUARIO' => 'required|string',
|
|
|
+ 'NUMERO_LINEA' => 'required|integer',
|
|
|
+ ]);
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "Se encontraron uno o más errores.",
|
|
|
+ $this->responseController->makeErrors($validator->errors()->messages()),
|
|
|
+ 401
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ DB::beginTransaction();
|
|
|
+ $requestData = $request->all();
|
|
|
+
|
|
|
+ $arrResponseCheckUser = $this->resourcesController->checkUserEnc($requestData['USUARIO'], $requestData['NUMERO_LINEA']);
|
|
|
+ if ($arrResponseCheckUser['error']) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, $arrResponseCheckUser['msg'], [], 401);
|
|
|
+ }
|
|
|
+ $user = $arrResponseCheckUser['response'];
|
|
|
+
|
|
|
+ try {
|
|
|
+ $validateExists = DB::table("S002V01TFAMI")->where([
|
|
|
+ ['FAMI_COFA', '=', $requestData['FAMILIA']],
|
|
|
+ ['FAMI_NULI', '=', $requestData['NUMERO_LINEA']],
|
|
|
+ ])->exists();
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, "Ocurrió un error verificar la existencia de la familia.", $th->getMessage(), 500);
|
|
|
+ }
|
|
|
+ if ($validateExists === false) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, "La familia no existe.", [], 500);
|
|
|
+ }
|
|
|
+ unset($validateExists);
|
|
|
+
|
|
|
+ try {
|
|
|
+ $validateExists = DB::table('S002V01TSUBF')
|
|
|
+ ->where([
|
|
|
+ ['SUBF_NULI', '=', $requestData['NUMERO_LINEA']],
|
|
|
+ ['SUBF_COFA', '=', $requestData['FAMILIA']],
|
|
|
+ ['SUBF_COSU', '=', $requestData['SUBFAMILIA']],
|
|
|
+ ])->exists();
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, "Ocurrió un error verificar la existencia de la subfamilia.", $th->getMessage(), 500);
|
|
|
+ }
|
|
|
+ if ($validateExists === false) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, "La subfamilia no existe.", [], 500);
|
|
|
+ }
|
|
|
+ unset($validateExists);
|
|
|
+
|
|
|
+ $now = $this->functionsController->now();
|
|
|
+ $currentDate = $now->toDateTimeString();
|
|
|
+
|
|
|
+ try {
|
|
|
+ $idArticle = DB::table('S002V01TARTI')
|
|
|
+ ->insertGetId([
|
|
|
+ 'ARTI_NULI' => $requestData['NUMERO_LINEA'],
|
|
|
+ 'ARTI_COFA' => $requestData['FAMILIA'],
|
|
|
+ 'ARTI_COSU' => $requestData['SUBFAMILIA'],
|
|
|
+ 'ARTI_CODI' => $requestData['CODIGO'],
|
|
|
+ 'ARTI_NOMB' => $requestData['ARTICULO'],
|
|
|
+ 'ARTI_USRE' => $user,
|
|
|
+ 'ARTI_FERE' => $currentDate,
|
|
|
+ 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
|
|
|
+ ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, "Ocurrió un error al registrar el artículo.", $th->getMessage(), 500);
|
|
|
+ }
|
|
|
+ if ($idArticle <= 0) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, "No se pudo registra el artículo.", [], 500);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($requestData['DESCRIPCION_ARTICULO'] as $keyDesc => $descriptions) {
|
|
|
+
|
|
|
+ // codeFile
|
|
|
+
|
|
|
+ foreach ($descriptions['ARCHIVOS'] as $files) {
|
|
|
+ $idFile = $this->encController->decrypt($files['ID']);
|
|
|
+ try {
|
|
|
+ $tempFile = DB::table('S002V01TARTE')
|
|
|
+ ->where([
|
|
|
+ ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
|
|
|
+ ['ARTE_IDAR', '=', $idFile],
|
|
|
+ ])->first();
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, "Ocurrió un error al obtener los archivos temporales.", $th->getMessage(), 500);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ry {
|
|
|
+ $arrCodeImages = array();
|
|
|
+ foreach ($information['IMAGEN'] as $key => $encIdFile) {
|
|
|
+ $idFile = $this->encController->decrypt($encIdFile);
|
|
|
+ $tempFile = DB::table('S002V01TARTE')->where([
|
|
|
+ ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
|
|
|
+ ['ARTE_IDAR', '=', $idFile],
|
|
|
+ ])->first();
|
|
|
+ if(is_null($tempFile)){
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG005: El archivo consultado no está registrado', [], 404);
|
|
|
+ }else if($tempFile->ARTE_ESTA == 'Eliminado'){
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG006: El archivo consultado está eliminado', [], 404);
|
|
|
+ }
|
|
|
+ $fileResponse = $this->documentManagementController->moveFinalFile(
|
|
|
+ intval($requestData['NUMERO_LINEA']),
|
|
|
+ 'GEAD',
|
|
|
+ 'FO',
|
|
|
+ $tempFile,
|
|
|
+ $usuario,
|
|
|
+ );
|
|
|
+ if(!$fileResponse[0]){
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG007: '.$fileResponse[1], [], 400);
|
|
|
+ }
|
|
|
+ $arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
|
|
|
+ }
|
|
|
+ $jsonImages = json_encode($arrCodeImages);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG008: Ocurrió un error al obtener la URL pública de las imágenes.", $th->getMessage(), 500);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $idDescription = DB::table('S002V01TDEAR')
|
|
|
+ ->insertGetId([
|
|
|
+ 'DEAR_NULI' => $requestData['NUMERO_LINEA'],
|
|
|
+ 'DEAR_IMAG' => $codeFile,
|
|
|
+ 'DEAR_DESC' => $descriptions['DESCRIPCION'],
|
|
|
+ 'DEAR_CARA' => $descriptions['CARACTERISTICAS'],
|
|
|
+ 'DEAR_COWE' => true,
|
|
|
+ 'DEAR_IDUN' => $descriptions['ID_UNIDAD'],
|
|
|
+ 'DEAR_NUPR' => $descriptions['NUMERO_PROVEEDOR'],
|
|
|
+ 'DEAR_IDAR' => $idArticle,
|
|
|
+ 'DEAR_USRE' => $user,
|
|
|
+ 'DEAR_FERE' => $currentDate,
|
|
|
+ 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
|
|
|
+ ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ //throw $th;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public function updateArtitles(Request $request) {
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'NO' => 'required|string',
|
|
|
@@ -932,7 +1091,7 @@ class ArtitleController extends Controller {
|
|
|
'FAMILIA' => 'required|string',
|
|
|
'SUBFAMILIA' => 'required|string',
|
|
|
'USUARIO' => 'required|string',
|
|
|
- 'NUMERO_LINEA' => 'required|string',
|
|
|
+ 'NUMERO_LINEA' => 'required|integer',
|
|
|
'INFORMATION' => 'required',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
@@ -1304,7 +1463,7 @@ class ArtitleController extends Controller {
|
|
|
public function deleteArtitle(Request $request) {
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'NUMERO_ARTITULO' => 'required|string',
|
|
|
- 'NUMERO_LINEA' => 'required|string',
|
|
|
+ 'NUMERO_LINEA' => 'required|integer',
|
|
|
'USUARIO' => 'required|string',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
@@ -1577,6 +1736,7 @@ class ArtitleController extends Controller {
|
|
|
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
|
|
|
}
|
|
|
+
|
|
|
public function updateUnit (Request $request, $idUnit) {
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'UNIDAD' => 'required|string',
|
|
|
@@ -1645,6 +1805,7 @@ class ArtitleController extends Controller {
|
|
|
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Modificación Exitosa");
|
|
|
}
|
|
|
+
|
|
|
public function getUnitById ($idUnit, $user, $line) {
|
|
|
|
|
|
$arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
|
|
|
@@ -1692,6 +1853,8 @@ class ArtitleController extends Controller {
|
|
|
public function deleteUnitById (Request $request, $idUnit) {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public function registerDescriptionArtitle () {}
|
|
|
}
|
|
|
|
|
|
|