|
|
@@ -43,7 +43,7 @@ class ArtitleController extends Controller {
|
|
|
'FAMI_NOMB AS FAMILIA',
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETFAMILY000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
}
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFamilias);
|
|
|
}
|
|
|
@@ -54,20 +54,18 @@ class ArtitleController extends Controller {
|
|
|
$arrFamiliasActives = DB::table('S002V01TFAMI')
|
|
|
->where('FAMI_ESTA', '=', 'Activo')
|
|
|
->get([
|
|
|
- 'FAMI_IDFA AS ID_FAMILIA',
|
|
|
- 'FAMI_NOMB AS FAMILIA',
|
|
|
+ 'FAMI_IDFA',
|
|
|
+ 'FAMI_NOMB',
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETFAMILIACTIVE000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
}
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO", $arrFamiliasActives);
|
|
|
}
|
|
|
|
|
|
// Función para obtener las familias y las subfamilias activas
|
|
|
public function getFamiliesAndSubfamilies ($line) {
|
|
|
- // Obtener las familias
|
|
|
try {
|
|
|
- $arrFamilias = array();
|
|
|
$arrFamilias = DB::table('S002V01TFAMI')
|
|
|
->where('FAMI_ESTA', '=', 'Activo')
|
|
|
->where('FAMI_NULI', '=', $line)
|
|
|
@@ -76,12 +74,10 @@ class ArtitleController extends Controller {
|
|
|
'FAMI_NOMB AS FAMILIA',
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET000: No se pudo realizar la consulta de las familias en la base.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETFAMILYS000: No se pudo realizar la consulta de las familias en la base.", $th->getMessage(), 500);
|
|
|
}
|
|
|
-
|
|
|
- // Obtener las subfamilias
|
|
|
+
|
|
|
try {
|
|
|
- $arrSubfamilias = array();
|
|
|
$arrSubfamilias = DB::table('S002V01TSUBF')
|
|
|
->where('SUBF_ESTA', '=', 'Activo')
|
|
|
->where('SUBF_NULI', '=', $line)
|
|
|
@@ -91,38 +87,23 @@ class ArtitleController extends Controller {
|
|
|
'SUBF_IDFA AS ID_FAMILIA',
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET001: No se pudo realizar la consulta de las subfamilias en la base.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETFAMILYS001: No se pudo realizar la consulta de las subfamilias en la base.", $th->getMessage(), 500);
|
|
|
}
|
|
|
|
|
|
- try {
|
|
|
- $arrFamilasAndSubfamilias = array();
|
|
|
- foreach ($arrFamilias as $familias) {
|
|
|
- // Se genera el arreglo con las familias
|
|
|
- $arrFamilasTemp = array(
|
|
|
- "ID" => $familias->ID_FAMILIA,
|
|
|
- "NOMBRE" => $familias->FAMILIA,
|
|
|
- "SUBFAMILIAS" => array()
|
|
|
- );
|
|
|
-
|
|
|
- // Se iteran todas las subfamilias
|
|
|
- foreach ($arrSubfamilias as $subfamilias) {
|
|
|
- // Se asignan al arreglo temporal las subfamilias a las familias pertenecientes
|
|
|
- if ( $familias->ID_FAMILIA == $subfamilias->ID_FAMILIA ) {
|
|
|
- $arrFamilasTemp["SUBFAMILIAS"][] = array(
|
|
|
- "ID" => $subfamilias->ID_SUBFAMILIA,
|
|
|
- "NOMBRE" => $subfamilias->SUBFAMILIA,
|
|
|
- );
|
|
|
- }
|
|
|
+ $arrFamilasAndSubfamilias = array();
|
|
|
+ foreach ($arrFamilias as $keyFamilias => $familias) {
|
|
|
+ $familias->SUBFAMILIAS = array();
|
|
|
+ foreach ($arrSubfamilias as $keySubfamilias => $subfamilias) {
|
|
|
+ if ($familias->ID_FAMILIA == $subfamilias->ID_FAMILIA) {
|
|
|
+ $familias->SUBFAMILIAS[] = array(
|
|
|
+ "ID_SUBFAMILIA" => $subfamilias->ID_SUBFAMILIA,
|
|
|
+ "SUBFAMILIA" => $subfamilias->SUBFAMILIA,
|
|
|
+ );
|
|
|
}
|
|
|
-
|
|
|
- // Se asigna al arreglo final
|
|
|
- $arrFamilasAndSubfamilias[] = $arrFamilasTemp;
|
|
|
}
|
|
|
- } catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET002: Ocurrió un error al generar la respuesta con las familias y subfamilias.", [], 500);
|
|
|
}
|
|
|
|
|
|
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFamilasAndSubfamilias);
|
|
|
+ return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFamilias);
|
|
|
}
|
|
|
|
|
|
public function registerFamily(Request $request){
|
|
|
@@ -190,7 +171,7 @@ class ArtitleController extends Controller {
|
|
|
'UNID_FEMO AS FECHA_MODIFICA',
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_UNIT_GET000: No se pudo realizar la consulta a la base.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETUNITS000: No se pudo realizar la consulta a la base.", [], 500);
|
|
|
}
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO", $arrFamilias);
|
|
|
}
|
|
|
@@ -209,7 +190,7 @@ class ArtitleController extends Controller {
|
|
|
'UNID_FEMO AS FECHA_MODIFICA',
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_UNIT_GET000: No se pudo realizar la consulta a la base.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETUNITACTIVE000: No se pudo realizar la consulta a la base.", [], 500);
|
|
|
}
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFamilias);
|
|
|
}
|
|
|
@@ -223,7 +204,7 @@ class ArtitleController extends Controller {
|
|
|
if ($valitador->fails()) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_UNIT_REG000: Se encontraron uno o más errores.",
|
|
|
+ "ERR_ARTITLE_REGUNIT000: Se encontraron uno o más errores.",
|
|
|
$this->responseController->makeErrors($valitador->errors()->messages()),
|
|
|
401
|
|
|
);
|
|
|
@@ -234,7 +215,7 @@ class ArtitleController extends Controller {
|
|
|
$usuario = $this->encController->decrypt($response['USER']);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_UNIT_REG001: Ocurrió un error al desencriptar los datos.", [], 401);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_REGUNIT001: Ocurrió un error al desencriptar los datos.", [], 401);
|
|
|
}
|
|
|
|
|
|
// $currentDate = Carbon::now()->timezone('America/Mazatlan')->toDateTimeString();
|
|
|
@@ -253,12 +234,12 @@ class ArtitleController extends Controller {
|
|
|
$valid = DB::table('S002V01TUNID')->insert($arrInsert);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_UNIT_REG002: Ocurrió un error al ingresar los registros.", [], 401);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_REGUNIT002: Ocurrió un error al ingresar los registros.", [], 401);
|
|
|
}
|
|
|
|
|
|
if (!$valid) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_UNIT_REG003: No se pudo ingresar los datos a la base de datos.", [], 401);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_REGUNIT003: No se pudo ingresar los datos a la base de datos.", [], 401);
|
|
|
}
|
|
|
DB::commit();
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
|
|
|
@@ -372,15 +353,27 @@ class ArtitleController extends Controller {
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
}
|
|
|
- $getArtitle = json_decode(json_encode($getArtitle), true);
|
|
|
- $arrArtitle = array();
|
|
|
+
|
|
|
foreach ($getArtitle as $artitle) {
|
|
|
+ // $artitle->URL_IMAGEN = json_decode($artitle->URL_IMAGEN);
|
|
|
|
|
|
- // $artitle['URL_IMAGEN'] = $this->decrypt($artitle['URL_IMAGEN']);
|
|
|
- $artitle['URL_IMAGEN'] = json_decode($artitle['URL_IMAGEN']);
|
|
|
- $arrArtitle[] = $artitle;
|
|
|
+ $arrImagen = json_decode($artitle->URL_IMAGEN);
|
|
|
+ $user = 'SFJKU29aaUtYbWwweFFzcmV4RVd6UEtNbWtlbU9VdkE3Vjg9fEU4N3pWWGFuWm5EbXBJaG1nZVl4RWJQcWtPTGZmT25H';
|
|
|
+
|
|
|
+ $arrUrlImage = array();
|
|
|
+ foreach ($arrImagen as $key => $imagen) {
|
|
|
+ $responseDocument = $this->documentManagementController->getPublicDocumentURL($imagen, $user, $line);
|
|
|
+
|
|
|
+ $arrResponseDocument = json_decode($responseDocument->original, true);
|
|
|
+ if ($arrResponseDocument['error']) {
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET003: Ocurrió un error al obtener la URL de la imágen.", [], 500);
|
|
|
+ }
|
|
|
+ $arrUrlImage[] = $arrResponseDocument['response']['public_uri'];
|
|
|
+ }
|
|
|
+ $artitle->URL_IMAGEN = $arrUrlImage;
|
|
|
+
|
|
|
}
|
|
|
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrArtitle);
|
|
|
+ return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $getArtitle);
|
|
|
}
|
|
|
|
|
|
public function getArtitlesByProvider(Request $request) {
|
|
|
@@ -392,7 +385,7 @@ class ArtitleController extends Controller {
|
|
|
if ($validator->fails()) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_ARTITLE_GET000: Se encontraron uno o más errores.",
|
|
|
+ "ERR_ARTITLE_GETBYPROVIDER000: Se encontraron uno o más errores.",
|
|
|
$this->responseController->makeErrors($validator->errors()->messages()),
|
|
|
401
|
|
|
);
|
|
|
@@ -432,34 +425,35 @@ class ArtitleController extends Controller {
|
|
|
"PROV_NOCO AS PROVEEDOR",
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET001: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYPROVIDER001: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
}
|
|
|
|
|
|
|
|
|
if ( empty($objArtitle) ) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET002: No se encontró el resultado deseado.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYPROVIDER002: No se encontró el resultado deseado.", [], 500);
|
|
|
}
|
|
|
|
|
|
$objArtitle['URL_IMAGEN'] = json_decode($objArtitle['URL_IMAGEN']);
|
|
|
- // $objArtitle['URL_IMAGEN'] = json_decode($objArtitle['URL_IMAGEN']);
|
|
|
|
|
|
try {
|
|
|
$arrInformation = DB::table('S002V01TINAR')
|
|
|
->where('INAR_ESTA', '=', 'Activo')
|
|
|
->where('INAR_NULI', '=', $dataRequest['lineNumber'])
|
|
|
->where('INAR_IDDE', '=', $objArtitle['ID_DESC_ARTI'])
|
|
|
+ ->join('S002V01TCAMO', 'CAMO_COMO', '=', 'INAR_COMO')
|
|
|
->get([
|
|
|
'INAR_IDIN AS NUMERO_INFORMACION',
|
|
|
'INAR_CODI AS CODIGO',
|
|
|
'INAR_MODE AS MODELO',
|
|
|
- 'INAR_MONE AS MONEDA',
|
|
|
+ // DB::raw('CONCAT("(", CAMO_COMO, ") ", CAMO_DESC) AS MONEDA'),
|
|
|
+ 'CAMO_COMO AS MONEDA',
|
|
|
+ 'CAMO_DESC AS MONEDA_DESCRIPCION',
|
|
|
'INAR_PREC AS PRECIO',
|
|
|
'INAR_MOMI AS MONTO_MINIMO',
|
|
|
- // 'INAR_CANT AS CANTIDAD',
|
|
|
'INAR_CARA AS CARACTERISTICAS',
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET003: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYPROVIDER003: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
}
|
|
|
|
|
|
$objArtitle['INFO_PRODUCTO'] = json_encode($arrInformation);
|
|
|
@@ -512,13 +506,22 @@ class ArtitleController extends Controller {
|
|
|
if ( empty($arrDescription) ) {
|
|
|
return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET003: No se encontró ninguna descripción.", [], 500);
|
|
|
}
|
|
|
-
|
|
|
+ // Se obtienen las URL de las imagenes de los artículos
|
|
|
foreach ($arrDescription as $description) {
|
|
|
+ $arrImagen = json_decode($description->IMAGEN);
|
|
|
+ $user = 'SFJKU29aaUtYbWwweFFzcmV4RVd6UEtNbWtlbU9VdkE3Vjg9fEU4N3pWWGFuWm5EbXBJaG1nZVl4RWJQcWtPTGZmT25H';
|
|
|
|
|
|
- $description->IMAGEN = json_decode($description->IMAGEN);
|
|
|
- // $description->IMAGEN = json_decode($description->IMAGEN);
|
|
|
- // var_dump($description->IMAGEN);
|
|
|
-
|
|
|
+ $arrUrlImage = array();
|
|
|
+ foreach ($arrImagen as $key => $imagen) {
|
|
|
+ $responseDocument = $this->documentManagementController->getPublicDocumentURL($imagen, $user, $line);
|
|
|
+
|
|
|
+ $arrResponseDocument = json_decode($responseDocument->original, true);
|
|
|
+ if ($arrResponseDocument['error']) {
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET003: Ocurrió un error al obtener la URL de la imágen.", [], 500);
|
|
|
+ }
|
|
|
+ $arrUrlImage[] = $arrResponseDocument['response']['public_uri'];
|
|
|
+ }
|
|
|
+ $description->IMAGEN = $arrUrlImage;
|
|
|
}
|
|
|
|
|
|
foreach ($arrDescription as $description) {
|
|
|
@@ -527,11 +530,12 @@ class ArtitleController extends Controller {
|
|
|
->where('INAR_IDDE', '=', $description->ID_DESCRIPCION)
|
|
|
->where('INAR_ESTA', '=', 'Activo')
|
|
|
->where('INAR_NULI', '=', $line)
|
|
|
+ ->join('S002V01TCAMO', 'CAMO_COMO', '=', 'INAR_COMO')
|
|
|
->get([
|
|
|
'INAR_IDIN AS NUMERO_DETALLE',
|
|
|
'INAR_CODI AS CODIGO',
|
|
|
'INAR_MODE AS MODELO',
|
|
|
- 'INAR_MONE AS MONEDA',
|
|
|
+ DB::raw('CONCAT("(", CAMO_COMO, ") ", CAMO_DESC) AS MONEDA'),
|
|
|
'INAR_PREC AS PRECIO',
|
|
|
'INAR_MOMI AS MONTO_MINIMO',
|
|
|
// 'INAR_CANT AS CANTIDAD',
|
|
|
@@ -561,7 +565,7 @@ class ArtitleController extends Controller {
|
|
|
'PROV_TEL2 AS TELEFONO2',
|
|
|
'PROV_XRFC AS RFC',
|
|
|
'PROV_XTAX AS TAXID',
|
|
|
- 'PROV_CORF AS GIRO_EMPRESA',
|
|
|
+ 'PROV_CRFI AS GIRO_EMPRESA',
|
|
|
'PROV_TIPO AS TIPO_EMPRESA',
|
|
|
'PROV_SIWE AS SITIO_WEB',
|
|
|
'PROV_MEPA AS METODO_PAGO',
|
|
|
@@ -601,7 +605,7 @@ class ArtitleController extends Controller {
|
|
|
"ARTI_FEMO AS FECHA_MODIFICA",
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET000: No se pudo realizar la consulta a la base.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETALL000: No se pudo realizar la consulta a la base.", [], 500);
|
|
|
}
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $resp);
|
|
|
}
|
|
|
@@ -642,7 +646,7 @@ class ArtitleController extends Controller {
|
|
|
if ($validator->fails()) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_ARTITLE_REG000: Se encontraron uno o más errores.",
|
|
|
+ "ERR_ARTITLE_REG001: Se encontraron uno o más errores.",
|
|
|
$this->responseController->makeErrors($validator->errors()->messages()),
|
|
|
401
|
|
|
);
|
|
|
@@ -663,7 +667,7 @@ class ArtitleController extends Controller {
|
|
|
if ($validator->fails()) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_ARTITLE_REG000: Se encontraron uno o más errores.",
|
|
|
+ "ERR_ARTITLE_REG002: Se encontraron uno o más errores.",
|
|
|
$this->responseController->makeErrors($validator->errors()->messages()),
|
|
|
401
|
|
|
);
|
|
|
@@ -674,7 +678,7 @@ class ArtitleController extends Controller {
|
|
|
if (gettype($imagen) != 'string') {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_ARTITLE_REG000: Se encontraron uno o más errores.",
|
|
|
+ "ERR_ARTITLE_REG003: Se encontraron uno o más errores.",
|
|
|
"Se se obtuvieron los ID de los archivos.",
|
|
|
401
|
|
|
);
|
|
|
@@ -686,7 +690,7 @@ class ArtitleController extends Controller {
|
|
|
$usuario = $this->encController->decrypt($requestData['USUARIO']);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG001: No se pudo obtener los datos del usuario", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG004: No se pudo obtener los datos del usuario", $th->getMessage(), 500);
|
|
|
}
|
|
|
|
|
|
// $currentDate = Carbon::now()->timezone('America/Mazatlan')->toDateTimeString();
|
|
|
@@ -706,7 +710,7 @@ class ArtitleController extends Controller {
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG002: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG005: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
}
|
|
|
|
|
|
foreach ($requestData['INFORMATION'] as $keyInformation => $information) {
|
|
|
@@ -721,9 +725,9 @@ class ArtitleController extends Controller {
|
|
|
])->first();
|
|
|
|
|
|
if(is_null($tempFile)){
|
|
|
- return $this->responseController->makeResponse(true, 'El archivo consultado no está registrado', [], 404);
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG006: El archivo consultado no está registrado', [], 404);
|
|
|
}else if($tempFile->ARTE_ESTA == 'Eliminado'){
|
|
|
- return $this->responseController->makeResponse(true, 'El archivo consultado está eliminado', [], 404);
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG007: El archivo consultado está eliminado', [], 404);
|
|
|
}
|
|
|
$fileResponse = $this->documentManagementController->moveFinalFile(
|
|
|
intval($requestData['NUMERO_LINEA']),
|
|
|
@@ -733,7 +737,7 @@ class ArtitleController extends Controller {
|
|
|
$usuario,
|
|
|
);
|
|
|
if(!$fileResponse[0]){
|
|
|
- return $this->responseController->makeResponse(true, $fileResponse[1], [], 400);
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG008: '.$fileResponse[1], [], 400);
|
|
|
}
|
|
|
$arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
|
|
|
}
|
|
|
@@ -755,7 +759,7 @@ class ArtitleController extends Controller {
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG004: Ocurrió un error al insertar los datos de la información del artículo.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG009: Ocurrió un error al insertar los datos de la información del artículo.", $th->getMessage(), 500);
|
|
|
}
|
|
|
$arrDetails = $information['DETAILS'];
|
|
|
|
|
|
@@ -764,7 +768,7 @@ class ArtitleController extends Controller {
|
|
|
'INAR_IDDE' => $idDescription,
|
|
|
'INAR_CODI' => $details['CODIGO'],
|
|
|
'INAR_MODE' => $details['MODELO'],
|
|
|
- 'INAR_MONE' => $details['MONEDA'],
|
|
|
+ 'INAR_COMO' => $details['MONEDA'],
|
|
|
'INAR_PREC' => $details['PRECIO'],
|
|
|
'INAR_MOMI' => $details['MONTO_MINIMO'],
|
|
|
// 'INAR_CANT' => $details['CANTIDAD'],
|
|
|
@@ -778,12 +782,12 @@ class ArtitleController extends Controller {
|
|
|
$validateDetails = DB::table('S002V01TINAR')->insert($insertDetails);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG005: Ocurrió un error al insertar los datos de los detalles del artículo.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG010: Ocurrió un error al insertar los datos de los detalles del artículo.", $th->getMessage(), 500);
|
|
|
}
|
|
|
|
|
|
if (!$validateDetails) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG006: No se pudo insertar los datos de los detalles.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG011: No se pudo insertar los datos de los detalles.", [], 500);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -812,7 +816,6 @@ class ArtitleController extends Controller {
|
|
|
}
|
|
|
DB::beginTransaction(); # Para impedir que las actualizaciones queden a incompletas
|
|
|
$requestData = $request->all();
|
|
|
-
|
|
|
foreach ($requestData['INFORMATION'] as $information) {
|
|
|
$validator = Validator::make($information, [
|
|
|
'NO' => 'required|integer',
|
|
|
@@ -872,7 +875,7 @@ class ArtitleController extends Controller {
|
|
|
$usuario = $this->encController->decrypt($requestData['USUARIO']);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD001: Ocurrió un error al desencriptar el usuario.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD004: Ocurrió un error al desencriptar el usuario.", [], 500);
|
|
|
}
|
|
|
|
|
|
$now = $this->functionsController->now();
|
|
|
@@ -880,25 +883,26 @@ class ArtitleController extends Controller {
|
|
|
|
|
|
$numeroArticulo = $requestData['NO'];
|
|
|
try {
|
|
|
- $resp = DB::table('S002V01TARTI')
|
|
|
+ $validateUpdate = DB::table('S002V01TARTI')
|
|
|
->where('ARTI_IDAR', '=', $numeroArticulo)
|
|
|
->where('ARTI_NULI', '=', $requestData['NUMERO_LINEA'])
|
|
|
->update([
|
|
|
- 'ARTI_CODI' => $requestData['CODIGO'],
|
|
|
- 'ARTI_IDFA' => $requestData['FAMILIA'],
|
|
|
- 'ARTI_IDSU' => $requestData['SUBFAMILIA'],
|
|
|
- 'ARTI_NOMB' => $requestData['ARTICULO'],
|
|
|
- 'ARTI_USMO' => $usuario,
|
|
|
- 'ARTI_FEMO' => $currentDate,
|
|
|
- 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
|
|
|
- ]);
|
|
|
- if (!$resp) {
|
|
|
- DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD002: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
- }
|
|
|
+ 'ARTI_CODI' => $requestData['CODIGO'],
|
|
|
+ 'ARTI_IDFA' => $requestData['FAMILIA'],
|
|
|
+ 'ARTI_IDSU' => $requestData['SUBFAMILIA'],
|
|
|
+ 'ARTI_NOMB' => $requestData['ARTICULO'],
|
|
|
+ 'ARTI_USMO' => $usuario,
|
|
|
+ 'ARTI_FEMO' => $currentDate,
|
|
|
+ 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
|
|
|
+ ]);
|
|
|
+
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD003: Ocurrió un error al modificar el registro.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD005: Ocurrió un error al modificar el registro.", [], 500);
|
|
|
+ }
|
|
|
+ if (!$validateUpdate) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD0006: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
}
|
|
|
|
|
|
$arrInformation = $requestData['INFORMATION'];
|
|
|
@@ -908,12 +912,13 @@ class ArtitleController extends Controller {
|
|
|
|
|
|
// Se verifica si la información ya está registrado o no
|
|
|
if ($information['ESTADO'] === 'Modificado' || $information['ESTADO'] === 'Activo') {
|
|
|
-
|
|
|
$arrCodeImages = array();
|
|
|
foreach ($information['IMAGEN'] as $key => $encIdFile) {
|
|
|
- var_dump($encIdFile);
|
|
|
+
|
|
|
$idFile = $this->encController->decrypt($encIdFile);
|
|
|
+ // var_dump($idFile);
|
|
|
$arrCode = explode('=', $idFile);
|
|
|
+
|
|
|
if ( count($arrCode) == 3 ) {
|
|
|
|
|
|
$arrStrucuteCode = explode("-", $arrCode[0]);
|
|
|
@@ -929,11 +934,10 @@ class ArtitleController extends Controller {
|
|
|
|
|
|
if (!$validateImage) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD003: La imagen con el código $idFile no existe.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD007ERR_ARTITLE_MOD007: : La imagen con el código $idFile no existe.", [], 500);
|
|
|
}
|
|
|
|
|
|
$arrCodeImages[] = $this->encController->encrypt($idFile);
|
|
|
- // $arrCodeImages[] = $idFile;
|
|
|
|
|
|
} else {
|
|
|
$tempFile = DB::table('S002V01TARTE')->where([
|
|
|
@@ -941,13 +945,12 @@ class ArtitleController extends Controller {
|
|
|
['ARTE_IDAR', '=', $idFile],
|
|
|
])->first();
|
|
|
|
|
|
-
|
|
|
if(is_null($tempFile)){
|
|
|
- return $this->responseController->makeResponse(true, 'El archivo consultado no está registrado', [], 404);
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD008: El archivo consultado no está registrado', [], 404);
|
|
|
}else if($tempFile->ARTE_ESTA == 'Eliminado'){
|
|
|
- return $this->responseController->makeResponse(true, 'El archivo consultado está eliminado', [], 404);
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD009: El archivo consultado está eliminado', [], 404);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$fileResponse = $this->documentManagementController->moveFinalFile(
|
|
|
intval($requestData['NUMERO_LINEA']),
|
|
|
'GEAD',
|
|
|
@@ -957,7 +960,7 @@ class ArtitleController extends Controller {
|
|
|
);
|
|
|
|
|
|
if(!$fileResponse[0]){
|
|
|
- return $this->responseController->makeResponse(true, $fileResponse[1], [], 400);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD010: ".$fileResponse[1], [], 400);
|
|
|
}
|
|
|
$arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
|
|
|
// $arrCodeImages[] = $fileResponse[1];
|
|
|
@@ -965,6 +968,7 @@ class ArtitleController extends Controller {
|
|
|
}
|
|
|
$jsonImages = json_encode($arrCodeImages);
|
|
|
|
|
|
+ // exit;
|
|
|
try {
|
|
|
$validate = DB::table('S002V01TDEAR')->where('DEAR_IDDE', '=', $numeroInformation)->update([
|
|
|
'DEAR_DESC' => $information['DESCRIPCION'],
|
|
|
@@ -980,11 +984,11 @@ class ArtitleController extends Controller {
|
|
|
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD004: Ocurrió un error al obtener el contenido.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD011: Ocurrió un error al obtener el contenido.", [], 500);
|
|
|
}
|
|
|
if (!$validate) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD005: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD012: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
}
|
|
|
|
|
|
$arrDetails = $information['DETAILS'];
|
|
|
@@ -995,7 +999,7 @@ class ArtitleController extends Controller {
|
|
|
$validate = DB::table('S002V01TINAR')->where('INAR_IDIN', '=', $numeroDetails)->update([
|
|
|
'INAR_CODI' => $details['CODIGO'],
|
|
|
'INAR_MODE' => $details['MODELO'],
|
|
|
- 'INAR_MONE' => $details['MONEDA'],
|
|
|
+ 'INAR_COMO' => $details['MONEDA'],
|
|
|
'INAR_PREC' => $details['PRECIO'],
|
|
|
'INAR_MOMI' => $details['MONTO_MINIMO'],
|
|
|
// 'INAR_CANT' => $details['CANTIDAD'],
|
|
|
@@ -1006,11 +1010,11 @@ class ArtitleController extends Controller {
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD006: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD013: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
|
|
|
}
|
|
|
if (!$validate) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD007: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD014: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
}
|
|
|
} else if ($details['ESTADO'] === 'Nuevo') {
|
|
|
try {
|
|
|
@@ -1018,7 +1022,7 @@ class ArtitleController extends Controller {
|
|
|
'INAR_IDDE' => $numeroInformation,
|
|
|
'INAR_CODI' => $details['CODIGO'],
|
|
|
'INAR_MODE' => $details['MODELO'],
|
|
|
- 'INAR_MONE' => $details['MONEDA'],
|
|
|
+ 'INAR_COMO' => $details['MONEDA'],
|
|
|
'INAR_PREC' => $details['PRECIO'],
|
|
|
'INAR_MOMI' => $details['MONTO_MINIMO'],
|
|
|
// 'INAR_CANT' => $details['CANTIDAD'],
|
|
|
@@ -1030,11 +1034,11 @@ class ArtitleController extends Controller {
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD008: Ocurrió un error al obtener el contenido.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD015: Ocurrió un error al obtener el contenido.", [], 500);
|
|
|
}
|
|
|
if (!$validate) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD009: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD016: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
}
|
|
|
} else if ($details['ESTADO'] === 'Eliminado') {
|
|
|
try {
|
|
|
@@ -1046,11 +1050,11 @@ class ArtitleController extends Controller {
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD010: Ocurrió un error al obtener el contenido.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD017: Ocurrió un error al obtener el contenido.", [], 500);
|
|
|
}
|
|
|
if (!$validate) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD011: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD018: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1075,7 +1079,7 @@ class ArtitleController extends Controller {
|
|
|
|
|
|
if (!$validateImage) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD003: La imagen con el código $idFile no existe.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD019: La imagen con el código $idFile no existe.", [], 500);
|
|
|
}
|
|
|
|
|
|
$arrCodeImages[] = $this->encController->encrypt($idFile);
|
|
|
@@ -1089,9 +1093,9 @@ class ArtitleController extends Controller {
|
|
|
|
|
|
|
|
|
if(is_null($tempFile)){
|
|
|
- return $this->responseController->makeResponse(true, 'El archivo consultado no está registrado', [], 404);
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD020: El archivo consultado no está registrado', [], 404);
|
|
|
}else if($tempFile->ARTE_ESTA == 'Eliminado'){
|
|
|
- return $this->responseController->makeResponse(true, 'El archivo consultado está eliminado', [], 404);
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD021: El archivo consultado está eliminado', [], 404);
|
|
|
}
|
|
|
|
|
|
$fileResponse = $this->documentManagementController->moveFinalFile(
|
|
|
@@ -1103,7 +1107,7 @@ class ArtitleController extends Controller {
|
|
|
);
|
|
|
|
|
|
if(!$fileResponse[0]){
|
|
|
- return $this->responseController->makeResponse(true, $fileResponse[1], [], 400);
|
|
|
+ return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD022: '.$fileResponse[1], [], 400);
|
|
|
}
|
|
|
|
|
|
$arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
|
|
|
@@ -1128,7 +1132,7 @@ class ArtitleController extends Controller {
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD013: Ocurrió un error al insertar los datos de la información del artículo.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD023: Ocurrió un error al insertar los datos de la información del artículo.", [], 500);
|
|
|
}
|
|
|
$arrDetails = $information['DETAILS'];
|
|
|
foreach ($arrDetails as $keyDetails => $details) {
|
|
|
@@ -1137,7 +1141,7 @@ class ArtitleController extends Controller {
|
|
|
'INAR_IDDE' => $numeroInformation,
|
|
|
'INAR_CODI' => $details['CODIGO'],
|
|
|
'INAR_MODE' => $details['MODELO'],
|
|
|
- 'INAR_MONE' => $details['MONEDA'],
|
|
|
+ 'INAR_COMO' => $details['MONEDA'],
|
|
|
'INAR_PREC' => $details['PRECIO'],
|
|
|
'INAR_MOMI' => $details['MONTO_MINIMO'],
|
|
|
// 'INAR_CANT' => $details['CANTIDAD'],
|
|
|
@@ -1149,7 +1153,7 @@ class ArtitleController extends Controller {
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD014: Ocurrió un error al insertar los datos de los detalles del artículo.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD024: Ocurrió un error al insertar los datos de los detalles del artículo.", [], 500);
|
|
|
}
|
|
|
}
|
|
|
} else if ($information['ESTADO'] === 'Eliminado') {
|
|
|
@@ -1162,14 +1166,15 @@ class ArtitleController extends Controller {
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD015: Ocurrió un error al obtener el contenido.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD025: Ocurrió un error al obtener el contenido.", [], 500);
|
|
|
}
|
|
|
if (!$validate) {
|
|
|
DB::rollBack();
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD016: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD026: Ocurrió un error al modificar en la tabla.", [], 500);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
DB::commit(); # Para guardar los cambios en la base de datos
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Modificación Exitosa");
|
|
|
}
|
|
|
@@ -1183,7 +1188,7 @@ class ArtitleController extends Controller {
|
|
|
if ($validator->fails()) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_ARTITLE_MOD000: Se encontraron uno o más errores.",
|
|
|
+ "ERR_ARTITLE_DEL000: Se encontraron uno o más errores.",
|
|
|
$this->responseController->makeErrors($validator->errors()->messages()),
|
|
|
401
|
|
|
);
|
|
|
@@ -1295,11 +1300,13 @@ class ArtitleController extends Controller {
|
|
|
->join('S002V01TSUBF', 'SUBF_IDSU', '=', 'ARTI_IDSU')
|
|
|
->join('S002V01TUNID', 'UNID_IDUN', '=', 'DEAR_IDUN')
|
|
|
->join('S002V01TPROV', 'PROV_NUPR', '=', 'DEAR_NUPR')
|
|
|
+ ->join('S002V01TCAMO', 'CAMO_COMO', '=', 'INAR_COMO')
|
|
|
->first([
|
|
|
'INAR_IDIN', // Identificador de Información del artículo
|
|
|
'INAR_CODI', // Código del artículo
|
|
|
'INAR_MODE', // Modelo del artículo
|
|
|
- 'INAR_MONE', // Moneda
|
|
|
+ // 'INAR_MONE', // Moneda
|
|
|
+ DB::raw('CONCAT("(", CAMO_COMO, ") ", CAMO_DESC) AS CAMO_COMO'),
|
|
|
'INAR_PREC', // Precio
|
|
|
// 'INAR_CANT', // Cantidad
|
|
|
'INAR_CARA', // Características
|
|
|
@@ -1340,11 +1347,10 @@ class ArtitleController extends Controller {
|
|
|
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
+ return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYINFORMATION000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
|
|
|
}
|
|
|
|
|
|
$objInformation['DEAR_IMAG'] = json_decode($objInformation['DEAR_IMAG']);
|
|
|
- // $objInformation['DEAR_IMAG'] = json_decode($objInformation['DEAR_IMAG']);
|
|
|
|
|
|
return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $objInformation);
|
|
|
}
|