ArtitleController.php 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
  1. <?php
  2. /*
  3. Desarrollador: Ing. Jean Jairo Benitez Meza
  4. Ultima Modificación: 10/10/2023
  5. Módulo: Gestión de Adquisiciones
  6. */
  7. namespace App\Http\Controllers;
  8. use Illuminate\Http\Request;
  9. use Illuminate\Support\Carbon;
  10. use Illuminate\Support\Facades\DB;
  11. use App\Http\Controllers\Controller;
  12. use Illuminate\Support\Facades\Validator;
  13. use App\Http\Controllers\ResponseController;
  14. use App\Http\Controllers\ResourcesController;
  15. use App\Http\Controllers\EncryptionController;
  16. use App\Http\Controllers\DocumentManagementController;
  17. use App\Http\Controllers\FunctionsController;
  18. class ArtitleController extends Controller {
  19. private $responseController;
  20. private $encController;
  21. private $resourcesController;
  22. private $documentManagementController;
  23. private $functionsController;
  24. public function __construct() {
  25. $this->responseController = new ResponseController();
  26. $this->encController = new EncryptionController();
  27. $this->resourcesController = new ResourcesController();
  28. $this->documentManagementController = new DocumentManagementController();
  29. $this->functionsController = new FunctionsController();
  30. }
  31. // Función para obtener las familias y las subfamilias activas
  32. public function getFamiliesAndSubfamilies ($user, $line) {
  33. try {
  34. $arrFamilias = DB::table('S002V01TFAMI')
  35. ->where('FAMI_ESTA', '=', 'Activo')
  36. ->where('FAMI_NULI', '=', $line)
  37. ->get([
  38. 'FAMI_COFA AS ID_FAMILIA',
  39. 'FAMI_NOFA AS FAMILIA',
  40. ]);
  41. } catch (\Throwable $th) {
  42. return $this->responseController->makeResponse(
  43. true,
  44. "ERR_ARTITLE_GETFAMILYS000: No se pudo realizar la consulta de las familias en la base.",
  45. $th->getMessage(),
  46. 500
  47. );
  48. }
  49. try {
  50. $arrSubfamilias = DB::table('S002V01TSUBF')
  51. ->where('SUBF_ESTA', '=', 'Activo')
  52. ->where('SUBF_NULI', '=', $line)
  53. ->get([
  54. 'SUBF_COSU AS ID_SUBFAMILIA',
  55. 'SUBF_NOSU AS SUBFAMILIA',
  56. 'SUBF_COFA AS ID_FAMILIA',
  57. ]);
  58. } catch (\Throwable $th) {
  59. return $this->responseController->makeResponse(
  60. true,
  61. "ERR_ARTITLE_GETFAMILYS001: No se pudo realizar la consulta de las subfamilias en la base.",
  62. $th->getMessage(),
  63. 500
  64. );
  65. }
  66. try {
  67. foreach ($arrFamilias as $keyFamilias => $familias) {
  68. $familias->SUBFAMILIAS = array();
  69. foreach ($arrSubfamilias as $keySubfamilias => $subfamilias) {
  70. if ($familias->ID_FAMILIA == $subfamilias->ID_FAMILIA) {
  71. $familias->SUBFAMILIAS[] = array(
  72. "ID_SUBFAMILIA" => $subfamilias->ID_SUBFAMILIA,
  73. "SUBFAMILIA" => $subfamilias->SUBFAMILIA,
  74. );
  75. }
  76. }
  77. }
  78. } catch (\Throwable $th) {
  79. return $this->responseController->makeResponse(
  80. true,
  81. "ERR_ARTITLE_GETFAMILYS002: Ocurrió un error al generar la respuesta de la consulta.",
  82. $th->getMessage(),
  83. 500
  84. );
  85. }
  86. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFamilias);
  87. }
  88. public function registerFamily(Request $request){
  89. $valitador = Validator::make($request->all(), [
  90. 'FAMILIA' => 'required|string|max:50',
  91. 'LINE' => 'required|integer',
  92. 'USER' => 'required|string'
  93. ]);
  94. if ($valitador->fails()) {
  95. return $this->responseController->makeResponse(
  96. true,
  97. "ERR_FAMILY_REG000: Se encontraron uno o más errores.",
  98. $this->responseController->makeErrors($valitador->errors()->messages()),
  99. 401
  100. );
  101. }
  102. DB::beginTransaction();
  103. $responseData = $request->all();
  104. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($responseData['USER'], $responseData['LINE']);
  105. if ($arrResponseCheckUser['error']) {
  106. DB::rollBack();
  107. return $this->responseController->makeResponse(true, 'ERR_FAMILY_REG001:'.$arrResponseCheckUser['msg'], [], 401);
  108. }
  109. $usuario = $arrResponseCheckUser['response'];
  110. $now = $this->functionsController->now();
  111. $currentDate = $now->toDateTimeString();
  112. try {
  113. $validateInsert = DB::table('S002V01TFAMI')->insert([
  114. "FAMI_NOFA" => trim($responseData['FAMILIA']),
  115. "FAMI_USRE" => $usuario,
  116. "FAMI_NULI" => $responseData['LINE'],
  117. "FAMI_FERE" => $currentDate,
  118. "FAMI_FEAR" => DB::raw('CURRENT_TIMESTAMP')
  119. ]);
  120. } catch (\Throwable $th) {
  121. DB::rollBack();
  122. return $this->responseController->makeResponse(true, "ERR_FAMILY_REG002: Ocurrió un error al ingresar los registros.", $th->getMessage(), 401);
  123. }
  124. if (!$validateInsert) {
  125. DB::rollBack();
  126. return $this->responseController->makeResponse(true, "ERR_FAMILY_REG003: No se pudo ingresar los datos a la base de datos.", [], 401);
  127. }
  128. DB::commit();
  129. return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
  130. }
  131. public function getUnits($user, $line) {
  132. try {
  133. $arrFamilias = DB::table('S002V01TUNID')
  134. ->where('UNID_NULI', '=', $line)
  135. ->get([
  136. 'UNID_IDUN AS ID_UNIDAD',
  137. 'UNID_NOMB AS UNIDAD',
  138. 'UNID_ESTA AS ESTADO',
  139. 'UNID_USRE AS USUARIO_REGISTRA',
  140. 'UNID_FERE AS FECHA_REGISTRA',
  141. 'UNID_USMO AS USUARIO_MODIFICA',
  142. 'UNID_FEMO AS FECHA_MODIFICA',
  143. ]);
  144. } catch (\Throwable $th) {
  145. return $this->responseController->makeResponse(
  146. true,
  147. "ERR_ARTITLE_GETUNITS000: No se pudo realizar la consulta a la base.",
  148. $th->getMessage(),
  149. 500
  150. );
  151. }
  152. return $this->responseController->makeResponse(false, "ÉXITO: Consulta exitosa", $arrFamilias);
  153. }
  154. public function getUnitsActives($user, $line) {
  155. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
  156. if ($arrResponseCheckUser['error']) {
  157. DB::rollBack();
  158. return $this->responseController->makeResponse(true, 'ERR_UNITS_GETACTIVES000:'.$arrResponseCheckUser['msg'], [], 401);
  159. }
  160. try {
  161. $arrFamilias = DB::table('S002V01TUNID')
  162. ->where('UNID_NULI', '=', $line)
  163. ->where('UNID_ESTA', '=', 'Activo')
  164. ->get([
  165. 'UNID_IDUN AS ID_UNIDAD',
  166. 'UNID_NOMB AS UNIDAD',
  167. 'UNID_USRE AS USUARIO_REGISTRA',
  168. 'UNID_FERE AS FECHA_REGISTRA',
  169. 'UNID_USMO AS USUARIO_MODIFICA',
  170. 'UNID_FEMO AS FECHA_MODIFICA',
  171. ]);
  172. } catch (\Throwable $th) {
  173. return $this->responseController->makeResponse(
  174. true,
  175. "ERR_UNITS_GETACTIVES001: No se pudo realizar la consulta a la base.",
  176. $th->getMessage(),
  177. 500
  178. );
  179. }
  180. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFamilias);
  181. }
  182. public function registerUnit(Request $request){
  183. $valitador = Validator::make($request->all(), [
  184. 'UNIDAD' => 'required|string|max:50',
  185. 'LINE' => 'required|integer',
  186. 'USER' => 'required|string'
  187. ]);
  188. if ($valitador->fails()) {
  189. return $this->responseController->makeResponse(
  190. true,
  191. "ERR_UNITS_REG000: Se encontraron uno o más errores.",
  192. $this->responseController->makeErrors($valitador->errors()->messages()),
  193. 401
  194. );
  195. }
  196. DB::beginTransaction();
  197. $responseData = $request->all();
  198. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($responseData['USER'], $responseData['LINE']);
  199. if ($arrResponseCheckUser['error']) {
  200. DB::rollBack();
  201. return $this->responseController->makeResponse(true, 'ERR_UNITS_REG001:'.$arrResponseCheckUser['msg'], [], 401);
  202. }
  203. $usuario = $arrResponseCheckUser['response'];
  204. $now = $this->functionsController->now();
  205. $currentDate = $now->toDateTimeString();
  206. try {
  207. $validateInsert = DB::table('S002V01TUNID')->insert([
  208. "UNID_NOMB" => trim($responseData['UNIDAD']),
  209. "UNID_USRE" => $usuario,
  210. "UNID_NULI" => $responseData['LINE'],
  211. "UNID_FERE" => $currentDate,
  212. "UNID_FEAR" => DB::raw('CURRENT_TIMESTAMP')
  213. ]);
  214. } catch (\Throwable $th) {
  215. DB::rollBack();
  216. return $this->responseController->makeResponse(
  217. true,
  218. "ERR_UNITS_REG002: Ocurrió un error al ingresar los registros.",
  219. $th->getMessage(),
  220. 401
  221. );
  222. }
  223. if (!$validateInsert) {
  224. DB::rollBack();
  225. return $this->responseController->makeResponse(
  226. true,
  227. "ERR_UNITS_REG003: No se pudo ingresar los datos a la base de datos.",
  228. [],
  229. 401
  230. );
  231. }
  232. DB::commit();
  233. return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
  234. }
  235. public function registerSubfamily(Request $request){
  236. $valitador = Validator::make($request->all(), [
  237. 'ID_FAMILIA' => 'required|integer',
  238. 'SUBFAMILIA' => 'required|string|max:50',
  239. 'LINE' => 'required|integer',
  240. 'USER' => 'required|string'
  241. ]);
  242. if ($valitador->fails()) {
  243. return $this->responseController->makeResponse(
  244. true,
  245. "ERR_SUBFAMILY_REG000: Se encontraron uno o más errores.",
  246. $this->responseController->makeErrors($valitador->errors()->messages()),
  247. 401
  248. );
  249. }
  250. DB::beginTransaction();
  251. $responseData = $request->all();
  252. try {
  253. $validateExists = DB::table('S002V01TFAMI')
  254. ->where('FAMI_COFA', '=', trim($responseData['ID_FAMILIA']))
  255. ->where('FAMI_ESTA', '=', 'Activo')
  256. ->where('FAMI_NULI', '=', $responseData['LINE'])
  257. ->exists();
  258. } catch (\Throwable $th) {
  259. DB::rollBack();
  260. return $this->responseController->makeResponse(
  261. true,
  262. "ERR_SUBFAMILY_REG001: Ocurrió al verificar la Familia.",
  263. $th->getMessage(),
  264. 401
  265. );
  266. }
  267. if (!$validateExists) {
  268. return $this->responseController->makeResponse(
  269. true,
  270. "ERR_SUBFAMILY_REG002: La Familia seleccionada no existe.",
  271. [],
  272. 401
  273. );
  274. }
  275. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($responseData['USER'], $responseData['LINE']);
  276. if ($arrResponseCheckUser['error']) {
  277. DB::rollBack();
  278. return $this->responseController->makeResponse(true, 'ERR_SUBFAMILY_REG003:'.$arrResponseCheckUser['msg'], [], 401);
  279. }
  280. $user = $arrResponseCheckUser['response'];
  281. $now = $this->functionsController->now();
  282. $currentDate = $now->toDateTimeString();
  283. try {
  284. $validateInsert = DB::table('S002V01TSUBF')->insert([
  285. "SUBF_COFA" => $responseData['ID_FAMILIA'],
  286. "SUBF_NOSU" => $responseData['SUBFAMILIA'],
  287. "SUBF_USRE" => $user,
  288. "SUBF_NULI" => $responseData['LINE'],
  289. "SUBF_FERE" => $currentDate,
  290. "SUBF_FEAR" => DB::raw('CURRENT_TIMESTAMP')
  291. ]);
  292. } catch (\Throwable $th) {
  293. DB::rollBack();
  294. return $this->responseController->makeResponse(
  295. true,
  296. "ERR_SUBFAMILY_REG004: Ocurrió un error al ingresar los registros.",
  297. $th->getMessage(),
  298. 401
  299. );
  300. }
  301. if (!$validateInsert) {
  302. DB::rollBack();
  303. return $this->responseController->makeResponse(
  304. true,
  305. "ERR_SUBFAMILY_REG005: No se pudo ingresar los datos a la base de datos.",
  306. [],
  307. 401
  308. );
  309. }
  310. DB::commit();
  311. return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
  312. }
  313. public function getArtitles($user, $line) {
  314. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
  315. if ($arrResponseCheckUser['error']) {
  316. DB::rollBack();
  317. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_GET000:'.$arrResponseCheckUser['msg'], [], 401);
  318. }
  319. try {
  320. $getArtitle = DB::table('S002V01TARTI')
  321. ->where("ARTI_NULI", "=", $line)
  322. ->where("FAMI_NULI", "=", $line)
  323. ->where("SUBF_NULI", "=", $line)
  324. ->where("DEAR_NULI", "=", $line)
  325. ->where("PROV_NULI", "=", $line)
  326. ->where("UNID_NULI", "=", $line)
  327. ->where("ARTI_ESTA", "=", "Activo")
  328. ->where("FAMI_ESTA", "=", "Activo")
  329. ->where("SUBF_ESTA", "=", "Activo")
  330. ->where("DEAR_ESTA", "=", "Activo")
  331. ->where("PROV_ESTA", "=", "Activo")
  332. ->where("UNID_ESTA", "=", "Activo")
  333. ->join("S002V01TFAMI", "ARTI_COFA", "=", "FAMI_COFA")
  334. ->join("S002V01TSUBF", "ARTI_COSU", "=", "SUBF_COSU")
  335. ->join("S002V01TDEAR", "ARTI_IDAR", "=", "DEAR_IDAR")
  336. ->join("S002V01TPROV", "DEAR_NUPR", "=", "PROV_NUPR")
  337. ->join("S002V01TUNID", "DEAR_IDUN", "=", "UNID_IDUN")
  338. ->get([
  339. "DEAR_IDDE AS ID_DESC_ARTI",
  340. "ARTI_IDAR AS ID_ARTICULO",
  341. "ARTI_NOMB AS MODELO",
  342. "FAMI_COFA AS ID_FAMILIA",
  343. "FAMI_NOFA AS FAMILIA",
  344. "SUBF_COSU AS ID_SUBFAMILIA",
  345. "SUBF_NOSU AS SUBFAMILIA",
  346. "DEAR_DESC AS DESCRIPCION",
  347. "DEAR_CARA AS CARACTERISTICAS",
  348. "DEAR_COWE AS COMPRA_WEB",
  349. "DEAR_IDUN AS TIPO_UNIDAD",
  350. "DEAR_IMAG AS URL_IMAGEN",
  351. "PROV_NUPR AS ID_PROVEEDOR",
  352. "PROV_NOCO AS PROVEEDOR",
  353. ]);
  354. } catch (\Throwable $th) {
  355. return $this->responseController->makeResponse(
  356. true,
  357. "ERR_ARTITLE_GET001: No se pudo realizar la consulta a la base.",
  358. $th->getMessage(),
  359. 500
  360. );
  361. }
  362. try {
  363. foreach ($getArtitle as $artitle) {
  364. $arrImagen = json_decode($artitle->URL_IMAGEN);
  365. $arrUrlImage = array();
  366. foreach ($arrImagen as $key => $imagen) {
  367. $responseDocument = $this->documentManagementController->privateGetPublicDocumentURL($imagen, $user, $line);
  368. if ($responseDocument['error']) {
  369. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET002: Ocurrió un error al obtener la URL de la imágen.", [], 500);
  370. }
  371. $arrUrlImage[] = $responseDocument['response']['public_uri'];
  372. }
  373. $artitle->URL_IMAGEN = $arrUrlImage;
  374. }
  375. } catch (\Throwable $th) {
  376. return $this->responseController->makeResponse(
  377. true,
  378. "ERR_ARTITLE_GET003: Ocurrió un error al obtener las imangenes de los artículos.",
  379. $th->getMessage(),
  380. 500
  381. );
  382. }
  383. $getArtitle = json_decode(json_encode($getArtitle), true);
  384. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $getArtitle);
  385. }
  386. public function getArtitlesByProvider($artitle, $provider, $user, $line) {
  387. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
  388. if ($arrResponseCheckUser['error']) {
  389. DB::rollBack();
  390. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_GETBYPROVIDER000:'.$arrResponseCheckUser['msg'], [], 401);
  391. }
  392. try {
  393. $idArtitle = $this->encController->decrypt($artitle);
  394. } catch (\Throwable $th) {
  395. return $this->responseController->makeResponse(
  396. true,
  397. "ERR_ARTITLE_GETBYPROVIDER001: No se pudo realizar la consulta a la base.",
  398. $th->getMessage(),
  399. 500
  400. );
  401. }
  402. try {
  403. $idProvider = $this->encController->decrypt($provider);
  404. } catch (\Throwable $th) {
  405. return $this->responseController->makeResponse(
  406. true,
  407. "ERR_ARTITLE_GETBYPROVIDER002: No se pudo realizar la consulta a la base.",
  408. $th->getMessage(),
  409. 500
  410. );
  411. }
  412. try {
  413. $objArtitle = (array) DB::table('S002V01TDEAR')
  414. ->where("ARTI_NULI", "=", $line)
  415. ->where("DEAR_IDDE", "=", $idArtitle)
  416. ->where("DEAR_NUPR", "=", $idProvider)
  417. ->join("S002V01TARTI", "ARTI_IDAR", "=", "DEAR_IDAR")
  418. ->join("S002V01TFAMI", "ARTI_COFA", "=", "FAMI_COFA")
  419. ->join("S002V01TSUBF", "ARTI_COSU", "=", "SUBF_COSU")
  420. ->join("S002V01TPROV", "DEAR_NUPR", "=", "PROV_NUPR")
  421. ->join("S002V01TUNID", "DEAR_IDUN", "=", "UNID_IDUN")
  422. ->first([
  423. "DEAR_IDDE AS ID_DESC_ARTI",
  424. "ARTI_IDAR AS ID_ARTICULO",
  425. "ARTI_NOMB AS MODELO",
  426. "FAMI_COFA AS ID_FAMILIA",
  427. "FAMI_NOFA AS FAMILIA",
  428. "SUBF_COSU AS ID_SUBFAMILIA",
  429. "SUBF_NOSU AS SUBFAMILIA",
  430. "DEAR_DESC AS DESCRIPCION",
  431. "DEAR_CARA AS CARACTERISTICAS",
  432. "DEAR_COWE AS COMPRA_WEB",
  433. "UNID_IDUN AS ID_UNIDAD",
  434. "UNID_NOMB AS UNIDAD",
  435. "DEAR_IMAG AS URL_IMAGEN",
  436. "PROV_NUPR AS ID_PROVEEDOR",
  437. "PROV_NOCO AS PROVEEDOR",
  438. ]);
  439. } catch (\Throwable $th) {
  440. return $this->responseController->makeResponse(
  441. true,
  442. "ERR_ARTITLE_GETBYPROVIDER003: No se pudo realizar la consulta a la base.",
  443. $th->getMessage(),
  444. 500
  445. );
  446. }
  447. if ( empty($objArtitle) ) {
  448. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYPROVIDER004: No se encontró el resultado deseado.", [], 500);
  449. }
  450. try {
  451. $objArtitle['URL_IMAGEN'] = json_decode($objArtitle['URL_IMAGEN']);
  452. $arrUrlImage = array();
  453. foreach ($objArtitle['URL_IMAGEN'] as $key => $encImage) {
  454. $responseDocument = $this->documentManagementController->privateGetPublicDocumentURL($encImage, $user, $line);
  455. if ($responseDocument['error']) {
  456. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYPROVIDER005: Ocurrió un error al obtener la URL de la imágen.", [], 500);
  457. }
  458. $arrUrlImage[] = $responseDocument['response']['public_uri'];
  459. }
  460. $objArtitle['URL_IMAGEN'] = $arrUrlImage;
  461. } catch (\Throwable $th) {
  462. return $this->responseController->makeResponse(
  463. true,
  464. "ERR_ARTITLE_GETBYPROVIDER006: Ocurrió un error al obtner las imagenes de los artículos",
  465. $th->getMessage(),
  466. 500
  467. );
  468. }
  469. try {
  470. $arrInformation = DB::table('S002V01TINAR')
  471. ->where('INAR_ESTA', '=', 'Activo')
  472. ->where('INAR_NULI', '=', $line)
  473. ->where('INAR_IDDE', '=', $objArtitle['ID_DESC_ARTI'])
  474. ->join('S002V01TCAMO', 'CAMO_COMO', '=', 'INAR_COMO')
  475. ->get([
  476. 'INAR_IDIN AS NUMERO_INFORMACION',
  477. 'INAR_CODI AS CODIGO',
  478. 'INAR_MODE AS MODELO',
  479. 'CAMO_COMO AS MONEDA',
  480. 'CAMO_DESC AS MONEDA_DESCRIPCION',
  481. 'INAR_PREC AS PRECIO',
  482. 'INAR_MOMI AS MONTO_MINIMO',
  483. 'INAR_CARA AS CARACTERISTICAS',
  484. ]);
  485. } catch (\Throwable $th) {
  486. return $this->responseController->makeResponse(
  487. true,
  488. "ERR_ARTITLE_GETBYPROVIDER007: No se pudo realizar la consulta a la base.",
  489. $th->getMessage(),
  490. 500
  491. );
  492. }
  493. $objArtitle['INFO_PRODUCTO'] = json_encode($arrInformation);
  494. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $objArtitle);
  495. }
  496. public function getArtitleById($encIdArtitle, $user, $line) {
  497. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
  498. if ($arrResponseCheckUser['error']) {
  499. DB::rollBack();
  500. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_GETBYID000:'.$arrResponseCheckUser['msg'], [], 401);
  501. }
  502. try {
  503. $idArtitle = $this->encController->decrypt($encIdArtitle);
  504. } catch (\Throwable $th) {
  505. return $this->responseController->makeResponse(
  506. true,
  507. "ERR_ARTITLE_GETBYID001: Ocurrió un error al obtener el artículo.",
  508. $th->getMessage(),
  509. 500
  510. );
  511. }
  512. try {
  513. $arrArtitle = DB::table('S002V01TARTI')
  514. ->where('ARTI_IDAR', '=', $idArtitle)
  515. ->where('ARTI_ESTA', '=', 'Activo')
  516. ->where('ARTI_NULI', '=', $line)
  517. ->join("S002V01TFAMI", "ARTI_COFA", "=", "FAMI_COFA")
  518. ->join("S002V01TSUBF", "ARTI_COSU", "=", "SUBF_COSU")
  519. ->first([
  520. 'ARTI_IDAR AS NUMERO_ARTICULO',
  521. 'ARTI_CODI AS CODIGO',
  522. "FAMI_COFA AS ID_FAMILIA",
  523. "FAMI_NOFA AS FAMILIA",
  524. "SUBF_COSU AS ID_SUBFAMILIA",
  525. "SUBF_NOSU AS SUBFAMILIA",
  526. 'ARTI_NOMB AS ARTICULO',
  527. ]);
  528. } catch (\Throwable $th) {
  529. return $this->responseController->makeResponse(
  530. true,
  531. "ERR_ARTITLE_GETBYID002: No se pudo realizar la consulta a la base.",
  532. $th->getMessage(),
  533. 500
  534. );
  535. }
  536. try {
  537. $arrDescription = DB::table('S002V01TDEAR')
  538. ->where('DEAR_IDAR', '=', $idArtitle)
  539. ->where('DEAR_ESTA', '=', 'Activo')
  540. ->where('DEAR_NULI', '=', $line)
  541. ->join("S002V01TUNID", "DEAR_IDUN", "=", "UNID_IDUN")
  542. ->get([
  543. 'DEAR_IDDE AS ID_DESCRIPCION',
  544. 'DEAR_DESC AS DESCRIPCION',
  545. 'DEAR_CARA AS CARACTERISTICAS',
  546. 'DEAR_COWE AS COMPRA_WEB',
  547. 'DEAR_IDUN AS TIPO_UNIDAD',
  548. 'DEAR_IMAG AS IMAGEN',
  549. 'DEAR_NUPR AS PROVEEDOR',
  550. 'DEAR_ESTA AS ESTADO',
  551. ]);
  552. } catch (\Throwable $th) {
  553. return $this->responseController->makeResponse(
  554. true,
  555. "ERR_ARTITLE_GETBYID003: No se pudo realizar la consulta a la base.",
  556. $th->getMessage(),
  557. 500
  558. );
  559. }
  560. if ( empty($arrDescription) ) {
  561. return $this->responseController->makeResponse(
  562. true,
  563. "ERR_ARTITLE_GETBYID004: No se encontró ninguna descripción.",
  564. [],
  565. 500
  566. );
  567. }
  568. // Se obtienen las URL de las imagenes de los artículos
  569. try {
  570. foreach ($arrDescription as $description) {
  571. $arrImagen = json_decode($description->IMAGEN);
  572. $arrUrlImage = array();
  573. foreach ($arrImagen as $key => $imagen) {
  574. $responseDocument = $this->documentManagementController->privateGetPublicDocumentURL($imagen, $user, $line);
  575. if ($responseDocument['error']) {
  576. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYID005: Ocurrió un error al obtener la URL de la imágen.", [], 500);
  577. }
  578. $arrUrlImage[] = $responseDocument['response']['public_uri'];
  579. }
  580. $description->IMAGEN = $arrUrlImage;
  581. }
  582. } catch (\Throwable $th) {
  583. return $this->responseController->makeResponse(
  584. true,
  585. "ERR_ARTITLE_GETBYID006: Ocurrió un error al obtener las imágenes de los artículos.",
  586. [],
  587. 500
  588. );
  589. }
  590. foreach ($arrDescription as $description) {
  591. try {
  592. $arrDetails = DB::table('S002V01TINAR')
  593. ->where('INAR_IDDE', '=', $description->ID_DESCRIPCION)
  594. ->where('INAR_ESTA', '=', 'Activo')
  595. ->where('INAR_NULI', '=', $line)
  596. ->join('S002V01TCAMO', 'CAMO_COMO', '=', 'INAR_COMO')
  597. ->get([
  598. 'INAR_IDIN AS NUMERO_DETALLE',
  599. 'INAR_CODI AS CODIGO',
  600. 'INAR_MODE AS MODELO',
  601. DB::raw('CONCAT("(", CAMO_COMO, ") ", CAMO_DESC) AS MONEDA'),
  602. 'INAR_PREC AS PRECIO',
  603. 'INAR_MOMI AS MONTO_MINIMO',
  604. // 'INAR_CANT AS CANTIDAD',
  605. 'INAR_CARA AS CARACTERISTICAS',
  606. 'INAR_ESTA AS ESTADO',
  607. ]);
  608. } catch (\Throwable $th) {
  609. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYID007: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  610. }
  611. $description->DETALLES = $arrDetails;
  612. try {
  613. $objProdiver = DB::table('S002V01TPROV')
  614. ->where('PROV_NUPR', '=', $description->PROVEEDOR)
  615. ->where('PROV_ESTA', '=', 'Activo')
  616. ->where('PROV_NULI', '=', $line)
  617. ->first([
  618. 'PROV_NUPR',
  619. 'PROV_NOCO',
  620. 'PROV_NOMB',
  621. 'PROV_APPA',
  622. 'PROV_APMA',
  623. 'PROV_CORR',
  624. 'PROV_LAD1',
  625. 'PROV_TEL1',
  626. 'PROV_LAD2',
  627. 'PROV_TEL2',
  628. 'PROV_XRFC',
  629. 'PROV_XTAX',
  630. 'PROV_CRFI',
  631. 'PROV_TIPO',
  632. 'PROV_SIWE',
  633. 'PROV_MEPA',
  634. 'PROV_USRE',
  635. 'PROV_FERE',
  636. 'PROV_USMO',
  637. 'PROV_FEMO',
  638. ]);
  639. $description->PROVEEDOR = $objProdiver;
  640. } catch (\Throwable $th) {
  641. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYID008: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  642. }
  643. }
  644. $arrArtitle->INFORMACION = $arrDescription;
  645. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrArtitle);
  646. }
  647. public function getAllArtitles($user, $line) {
  648. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
  649. if ($arrResponseCheckUser['error']) {
  650. DB::rollBack();
  651. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_GETALL000:'.$arrResponseCheckUser['msg'], [], 401);
  652. }
  653. try {
  654. $arrArtitle = DB::table('S002V01TARTI')
  655. ->where("ARTI_NULI", "=", $line)
  656. ->join("S002V01TFAMI", "ARTI_COFA", "=", "FAMI_COFA")
  657. ->join("S002V01TSUBF", "ARTI_COSU", "=", "SUBF_COSU")
  658. ->get([
  659. "ARTI_IDAR AS ID_ARTICULO",
  660. "ARTI_NOMB AS MODELO",
  661. "FAMI_COFA AS ID_FAMILIA",
  662. "FAMI_NOFA AS FAMILIA",
  663. "SUBF_COSU AS ID_SUBFAMILIA",
  664. "SUBF_NOSU AS SUBFAMILIA",
  665. "ARTI_ESTA AS ESTADO",
  666. "ARTI_USRE AS USUARIO_REGISTRA",
  667. "ARTI_FERE AS FECHA_REGISTRA",
  668. "ARTI_USMO AS USUARIO_MODIFICA",
  669. "ARTI_FEMO AS FECHA_MODIFICA",
  670. ]);
  671. $arrArtitle = json_decode(json_encode($arrArtitle), true);
  672. } catch (\Throwable $th) {
  673. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETALL001: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  674. }
  675. $responseCheckLatestUpdate = $this->resourcesController->checkLatestUpdate($arrArtitle, $line);
  676. if ($responseCheckLatestUpdate['error']) {
  677. return $this->responseController->makeResponse(true, $responseCheckLatestUpdate['msg'], [], 500);
  678. }
  679. $arrArtitle = $responseCheckLatestUpdate['response'];
  680. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrArtitle);
  681. }
  682. public function registerArtitles(Request $request) {
  683. $validator = Validator::make($request->all(), [
  684. 'CODIGO' => 'required|string',
  685. 'ARTICULO' => 'required|string',
  686. 'FAMILIA' => 'required|string',
  687. 'SUBFAMILIA' => 'required|string',
  688. 'INFORMATION' => 'required|array',
  689. 'USUARIO' => 'required|string',
  690. 'NUMERO_LINEA' => 'required|string',
  691. ]);
  692. if ($validator->fails()) {
  693. return $this->responseController->makeResponse(
  694. true,
  695. "ERR_ARTITLE_REG000: Se encontraron uno o más errores.",
  696. $this->responseController->makeErrors($validator->errors()->messages()),
  697. 401
  698. );
  699. }
  700. DB::beginTransaction();
  701. $requestData = $request->all();
  702. foreach ($requestData['INFORMATION'] as $information) {
  703. $validator = Validator::make($information, [
  704. 'NO' => 'required|string',
  705. 'IMAGEN' => 'required|array',
  706. 'DESCRIPCION' => 'required|string',
  707. // 'CARACTERISTICAS' => '|string',
  708. 'TIPO_UNIDAD' => 'required|integer',
  709. 'PROVEEDOR' => 'required|string',
  710. 'COMPRA_WEB' => 'required|boolean',
  711. 'ESTADO' => 'required|string',
  712. 'DETAILS' => 'required|array',
  713. ]);
  714. if ($validator->fails()) {
  715. return $this->responseController->makeResponse(
  716. true,
  717. "ERR_ARTITLE_REG001: Se encontraron uno o más errores.",
  718. $this->responseController->makeErrors($validator->errors()->messages()),
  719. 401
  720. );
  721. }
  722. foreach ($information['DETAILS'] as $details) {
  723. $validator = Validator::make($details, [
  724. 'NO' => 'required|string',
  725. 'CODIGO' => 'required|string',
  726. 'MODELO' => 'required|string',
  727. 'MONEDA' => 'required|string',
  728. 'PRECIO' => 'required|string',
  729. 'MONTO_MINIMO' => 'required|string',
  730. 'ESTADO' => 'required|string',
  731. 'CARACTERISTICAS' => 'required|string',
  732. ]);
  733. if ($validator->fails()) {
  734. return $this->responseController->makeResponse(
  735. true,
  736. "ERR_ARTITLE_REG002: Se encontraron uno o más errores.",
  737. $this->responseController->makeErrors($validator->errors()->messages()),
  738. 401
  739. );
  740. }
  741. }
  742. }
  743. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($requestData['USUARIO'], $requestData['NUMERO_LINEA']);
  744. if ($arrResponseCheckUser['error']) {
  745. DB::rollBack();
  746. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG003:'.$arrResponseCheckUser['msg'], [], 401);
  747. }
  748. $usuario = $arrResponseCheckUser['response'];
  749. $now = $this->functionsController->now();
  750. $currentDate = $now->toDateTimeString();
  751. try {
  752. $idArtitle = DB::table('S002V01TARTI')->insertGetId([
  753. 'ARTI_CODI' => $requestData['CODIGO'],
  754. 'ARTI_COFA' => $requestData['FAMILIA'],
  755. 'ARTI_COSU' => $requestData['SUBFAMILIA'],
  756. 'ARTI_NOMB' => $requestData['ARTICULO'],
  757. 'ARTI_NULI' => $requestData['NUMERO_LINEA'],
  758. 'ARTI_USRE' => $usuario,
  759. 'ARTI_FERE' => $currentDate,
  760. 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  761. ]);
  762. } catch (\Throwable $th) {
  763. DB::rollBack();
  764. return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG004: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  765. }
  766. foreach ($requestData['INFORMATION'] as $keyInformation => $information) {
  767. try {
  768. $arrCodeImages = array();
  769. foreach ($information['IMAGEN'] as $key => $encIdFile) {
  770. $idFile = $this->encController->decrypt($encIdFile);
  771. $tempFile = DB::table('S002V01TARTE')->where([
  772. ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
  773. ['ARTE_IDAR', '=', $idFile],
  774. ])->first();
  775. if(is_null($tempFile)){
  776. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG005: El archivo consultado no está registrado', [], 404);
  777. }else if($tempFile->ARTE_ESTA == 'Eliminado'){
  778. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG006: El archivo consultado está eliminado', [], 404);
  779. }
  780. $fileResponse = $this->documentManagementController->moveFinalFile(
  781. intval($requestData['NUMERO_LINEA']),
  782. 'GEAD',
  783. 'FO',
  784. $tempFile,
  785. $usuario,
  786. );
  787. if(!$fileResponse[0]){
  788. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG007: '.$fileResponse[1], [], 400);
  789. }
  790. $arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
  791. }
  792. $jsonImages = json_encode($arrCodeImages);
  793. } catch (\Throwable $th) {
  794. DB::rollBack();
  795. return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG008: Ocurrió un error al obtener la URL pública de las imágenes.", $th->getMessage(), 500);
  796. }
  797. try {
  798. $idDescription = DB::table('S002V01TDEAR')->insertGetId([
  799. 'DEAR_DESC' => $information['DESCRIPCION'],
  800. 'DEAR_CARA' => $information['CARACTERISTICAS'],
  801. 'DEAR_COWE' => $information['COMPRA_WEB'],
  802. 'DEAR_IDUN' => $information['TIPO_UNIDAD'],
  803. 'DEAR_IMAG' => $jsonImages,
  804. 'DEAR_NUPR' => $information['PROVEEDOR'],
  805. 'DEAR_IDAR' => $idArtitle,
  806. 'DEAR_NULI' => $requestData['NUMERO_LINEA'],
  807. 'DEAR_USRE' => $usuario,
  808. 'DEAR_FERE' => $currentDate,
  809. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  810. ]);
  811. } catch (\Throwable $th) {
  812. DB::rollBack();
  813. 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);
  814. }
  815. $arrDetails = $information['DETAILS'];
  816. foreach ($arrDetails as $keyDetails => $details) {
  817. $insertDetails = [
  818. 'INAR_IDDE' => $idDescription,
  819. 'INAR_CODI' => $details['CODIGO'],
  820. 'INAR_MODE' => $details['MODELO'],
  821. 'INAR_COMO' => $details['MONEDA'],
  822. 'INAR_PREC' => $details['PRECIO'],
  823. 'INAR_MOMI' => $details['MONTO_MINIMO'],
  824. 'INAR_CARA' => $details['CARACTERISTICAS'],
  825. 'INAR_NULI' => $requestData['NUMERO_LINEA'],
  826. 'INAR_USRE' => $usuario,
  827. 'INAR_FERE' => $currentDate,
  828. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  829. ];
  830. try {
  831. $validateDetails = DB::table('S002V01TINAR')->insert($insertDetails);
  832. } catch (\Throwable $th) {
  833. DB::rollBack();
  834. return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG010: Ocurrió un error al insertar los datos de los detalles del artículo.", $th->getMessage(), 500);
  835. }
  836. if (!$validateDetails) {
  837. DB::rollBack();
  838. return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG011: No se pudo insertar los datos de los detalles.", [], 500);
  839. }
  840. }
  841. }
  842. DB::commit();
  843. return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
  844. }
  845. public function updateArtitles(Request $request) {
  846. $validator = Validator::make($request->all(), [
  847. 'NO' => 'required|string',
  848. 'CODIGO' => 'required|string',
  849. 'ARTICULO' => 'required|string',
  850. 'FAMILIA' => 'required|string',
  851. 'SUBFAMILIA' => 'required|string',
  852. 'USUARIO' => 'required|string',
  853. 'NUMERO_LINEA' => 'required|string',
  854. 'INFORMATION' => 'required',
  855. ]);
  856. if ($validator->fails()) {
  857. return $this->responseController->makeResponse(
  858. true,
  859. "ERR_ARTITLE_MOD000: Se encontraron uno o más errores.",
  860. $this->responseController->makeErrors($validator->errors()->messages()),
  861. 401
  862. );
  863. }
  864. DB::beginTransaction(); # Para impedir que las actualizaciones queden a incompletas
  865. $requestData = $request->all();
  866. foreach ($requestData['INFORMATION'] as $information) {
  867. $validator = Validator::make($information, [
  868. 'NO' => 'required|integer',
  869. 'IMAGEN' => 'required|array',
  870. 'DESCRIPCION' => 'required|string',
  871. // 'CARACTERISTICAS' => '|string',
  872. 'TIPO_UNIDAD' => 'required|integer',
  873. 'PROVEEDOR' => 'required|string',
  874. 'COMPRA_WEB' => 'required|boolean',
  875. 'ESTADO' => 'required|string',
  876. 'DETAILS' => 'required|array',
  877. ]);
  878. if ($validator->fails()) {
  879. return $this->responseController->makeResponse(
  880. true,
  881. "ERR_ARTITLE_MOD001: Se encontraron uno o más errores.",
  882. $this->responseController->makeErrors($validator->errors()->messages()),
  883. 401
  884. );
  885. }
  886. foreach ($information['DETAILS'] as $details) {
  887. $validator = Validator::make($details, [
  888. 'NO' => 'required|string',
  889. 'CODIGO' => 'required|string',
  890. 'MODELO' => 'required|string',
  891. 'MONEDA' => 'required|string',
  892. 'PRECIO' => 'required|string',
  893. 'MONTO_MINIMO' => 'required|string',
  894. 'ESTADO' => 'required|string',
  895. 'CARACTERISTICAS' => 'required|string',
  896. ]);
  897. if ($validator->fails()) {
  898. return $this->responseController->makeResponse(
  899. true,
  900. "ERR_ARTITLE_MOD002: Se encontraron uno o más errores.",
  901. $this->responseController->makeErrors($validator->errors()->messages()),
  902. 401
  903. );
  904. }
  905. }
  906. foreach ($information['IMAGEN'] as $key => $imagen) {
  907. if (gettype($imagen) != 'string') {
  908. return $this->responseController->makeResponse(
  909. true,
  910. "ERR_ARTITLE_MOD003: Se encontraron uno o más errores.",
  911. "Se se obtuvieron los ID de los archivos.",
  912. 401
  913. );
  914. }
  915. }
  916. }
  917. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($requestData['USUARIO'], $requestData['NUMERO_LINEA']);
  918. if ($arrResponseCheckUser['error']) {
  919. DB::rollBack();
  920. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD004:'.$arrResponseCheckUser['msg'], [], 401);
  921. }
  922. $usuario = $arrResponseCheckUser['response'];
  923. $now = $this->functionsController->now();
  924. $currentDate = $now->toDateTimeString();
  925. $numeroArticulo = $requestData['NO'];
  926. try {
  927. $validateUpdate = DB::table('S002V01TARTI')
  928. ->where('ARTI_IDAR', '=', $numeroArticulo)
  929. ->where('ARTI_NULI', '=', $requestData['NUMERO_LINEA'])
  930. ->update([
  931. 'ARTI_CODI' => $requestData['CODIGO'],
  932. 'ARTI_COFA' => $requestData['FAMILIA'],
  933. 'ARTI_COSU' => $requestData['SUBFAMILIA'],
  934. 'ARTI_NOMB' => $requestData['ARTICULO'],
  935. 'ARTI_USMO' => $usuario,
  936. 'ARTI_FEMO' => $currentDate,
  937. 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  938. ]);
  939. } catch (\Throwable $th) {
  940. DB::rollBack();
  941. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD005: Ocurrió un error al modificar el registro.", $th->getMessage(), 500);
  942. }
  943. if (!$validateUpdate) {
  944. DB::rollBack();
  945. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD006: Ocurrió un error al modificar en la tabla.", [], 500);
  946. }
  947. $arrInformation = $requestData['INFORMATION'];
  948. foreach ($arrInformation as $keyInformation => $information) {
  949. // Número de ID de información
  950. $numeroInformation = $information['NO'];
  951. // Se verifica si la información ya está registrado o no
  952. if ($information['ESTADO'] === 'Modificado' || $information['ESTADO'] === 'Activo') {
  953. $arrCodeImages = array();
  954. foreach ($information['IMAGEN'] as $key => $encIdFile) {
  955. $idFile = $this->encController->decrypt($encIdFile);
  956. $arrCode = explode('=', $idFile);
  957. if ( count($arrCode) == 3 ) {
  958. $arrStrucuteCode = explode("-", $arrCode[0]);
  959. $nameCode = explode(".", $arrCode[2]);
  960. $validateImage = DB::table('S002V01TAFAL')->where([
  961. ['AFAL_NULI', '=', $requestData['NUMERO_LINEA']],
  962. ['AFAL_COMO', '=', $arrStrucuteCode['1']],
  963. ['AFAL_CLDO', '=', $arrStrucuteCode['2']],
  964. ['AFAL_NOAR', '=', $nameCode[0]],
  965. ['AFAL_EXTE', '=', $nameCode[1]],
  966. ])->orderBy('AFAL_NUVE', 'desc')->exists();
  967. if (!$validateImage) {
  968. DB::rollBack();
  969. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD007: : La imagen con el código $idFile no existe.", [], 500);
  970. }
  971. $arrCodeImages[] = $this->encController->encrypt($idFile);
  972. } else {
  973. $tempFile = DB::table('S002V01TARTE')->where([
  974. ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
  975. ['ARTE_IDAR', '=', $idFile],
  976. ])->first();
  977. if(is_null($tempFile)){
  978. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD008: El archivo consultado no está registrado', $idFile, 404);
  979. }else if($tempFile->ARTE_ESTA == 'Eliminado'){
  980. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD009: El archivo consultado está eliminado', $tempFile, 404);
  981. }
  982. $fileResponse = $this->documentManagementController->moveFinalFile(
  983. intval($requestData['NUMERO_LINEA']),
  984. 'GEAD',
  985. 'FO',
  986. $tempFile,
  987. $usuario,
  988. );
  989. if(!$fileResponse[0]){
  990. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD010: ".$fileResponse[1], [], 400);
  991. }
  992. $arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
  993. // $arrCodeImages[] = $fileResponse[1];
  994. }
  995. }
  996. $jsonImages = json_encode($arrCodeImages);
  997. try {
  998. $validate = DB::table('S002V01TDEAR')->where('DEAR_IDDE', '=', $numeroInformation)->update([
  999. 'DEAR_DESC' => $information['DESCRIPCION'],
  1000. 'DEAR_CARA' => $information['CARACTERISTICAS'],
  1001. 'DEAR_COWE' => $information['COMPRA_WEB'],
  1002. 'DEAR_IDUN' => $information['TIPO_UNIDAD'],
  1003. 'DEAR_IMAG' => $jsonImages,
  1004. 'DEAR_NUPR' => $information['PROVEEDOR'],
  1005. 'DEAR_USMO' => $usuario,
  1006. 'DEAR_FEMO' => $currentDate,
  1007. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1008. ]);
  1009. } catch (\Throwable $th) {
  1010. DB::rollBack();
  1011. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD011: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1012. }
  1013. if (!$validate) {
  1014. DB::rollBack();
  1015. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD012: Ocurrió un error al modificar en la tabla.", [], 500);
  1016. }
  1017. $arrDetails = $information['DETAILS'];
  1018. foreach ($arrDetails as $keyDetails => $details) {
  1019. $numeroDetails = $details['NO'];
  1020. if ( $details['ESTADO'] === 'Modificado' || $details['ESTADO'] === 'Activo') {
  1021. try {
  1022. $validate = DB::table('S002V01TINAR')->where('INAR_IDIN', '=', $numeroDetails)->update([
  1023. 'INAR_CODI' => $details['CODIGO'],
  1024. 'INAR_MODE' => $details['MODELO'],
  1025. 'INAR_COMO' => $details['MONEDA'],
  1026. 'INAR_PREC' => $details['PRECIO'],
  1027. 'INAR_MOMI' => $details['MONTO_MINIMO'],
  1028. // 'INAR_CANT' => $details['CANTIDAD'],
  1029. 'INAR_CARA' => $details['CARACTERISTICAS'],
  1030. 'INAR_USMO' => $usuario,
  1031. 'INAR_FEMO' => $currentDate,
  1032. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1033. ]);
  1034. } catch (\Throwable $th) {
  1035. DB::rollBack();
  1036. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD013: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1037. }
  1038. if (!$validate) {
  1039. DB::rollBack();
  1040. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD014: Ocurrió un error al modificar en la tabla.", [], 500);
  1041. }
  1042. } else if ($details['ESTADO'] === 'Nuevo') {
  1043. try {
  1044. $validate = DB::table('S002V01TINAR')->insertGetId([
  1045. 'INAR_IDDE' => $numeroInformation,
  1046. 'INAR_CODI' => $details['CODIGO'],
  1047. 'INAR_MODE' => $details['MODELO'],
  1048. 'INAR_COMO' => $details['MONEDA'],
  1049. 'INAR_PREC' => $details['PRECIO'],
  1050. 'INAR_MOMI' => $details['MONTO_MINIMO'],
  1051. 'INAR_CARA' => $details['CARACTERISTICAS'],
  1052. 'INAR_NULI' => $requestData['NUMERO_LINEA'],
  1053. 'INAR_USRE' => $usuario,
  1054. 'INAR_FERE' => $currentDate,
  1055. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  1056. ]);
  1057. } catch (\Throwable $th) {
  1058. DB::rollBack();
  1059. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD015: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1060. }
  1061. if (!$validate) {
  1062. DB::rollBack();
  1063. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD016: Ocurrió un error al modificar en la tabla.", [], 500);
  1064. }
  1065. } else if ($details['ESTADO'] === 'Eliminado') {
  1066. try {
  1067. $validate = DB::table('S002V01TINAR')->where('INAR_IDIN', '=', $numeroDetails)->update([
  1068. 'INAR_ESTA' => 'Eliminado',
  1069. 'INAR_USMO' => $usuario,
  1070. 'INAR_FEMO' => $currentDate,
  1071. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1072. ]);
  1073. } catch (\Throwable $th) {
  1074. DB::rollBack();
  1075. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD017: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1076. }
  1077. if (!$validate) {
  1078. DB::rollBack();
  1079. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD018: Ocurrió un error al modificar en la tabla.", [], 500);
  1080. }
  1081. }
  1082. }
  1083. } else if ($information['ESTADO'] === 'Nuevo') {
  1084. $arrCodeImages = array();
  1085. foreach ($information['IMAGEN'] as $key => $encIdFile) {
  1086. $idFile = $this->encController->decrypt($encIdFile);
  1087. $arrCode = explode('=', $idFile);
  1088. if ( count($arrCode) == 3 ) {
  1089. $arrStrucuteCode = explode("-", $arrCode[0]);
  1090. $nameCode = explode(".", $arrCode[2]);
  1091. $validateImage = DB::table('S002V01TAFAL')->where([
  1092. ['AFAL_NULI', '=', $requestData['NUMERO_LINEA']],
  1093. ['AFAL_COMO', '=', $arrStrucuteCode['1']],
  1094. ['AFAL_CLDO', '=', $arrStrucuteCode['2']],
  1095. ['AFAL_NOAR', '=', $nameCode[0]],
  1096. ['AFAL_EXTE', '=', $nameCode[1]],
  1097. ])->orderBy('AFAL_NUVE', 'desc')->exists();
  1098. if (!$validateImage) {
  1099. DB::rollBack();
  1100. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD019: La imagen con el código $idFile no existe.", [], 500);
  1101. }
  1102. $arrCodeImages[] = $this->encController->encrypt($idFile);
  1103. } else {
  1104. $tempFile = DB::table('S002V01TARTE')->where([
  1105. ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
  1106. ['ARTE_IDAR', '=', $idFile],
  1107. ])->first();
  1108. if(is_null($tempFile)){
  1109. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD020: El archivo consultado no está registrado', [], 404);
  1110. }else if($tempFile->ARTE_ESTA == 'Eliminado'){
  1111. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD021: El archivo consultado está eliminado', [], 404);
  1112. }
  1113. $fileResponse = $this->documentManagementController->moveFinalFile(
  1114. intval($requestData['NUMERO_LINEA']),
  1115. 'GEAD',
  1116. 'FO',
  1117. $tempFile,
  1118. $usuario,
  1119. );
  1120. if(!$fileResponse[0]){
  1121. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD022: '.$fileResponse[1], [], 400);
  1122. }
  1123. $arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
  1124. }
  1125. }
  1126. $jsonImages = json_encode($arrCodeImages);
  1127. try {
  1128. $numeroInformation = DB::table('S002V01TDEAR')->insertGetId([
  1129. 'DEAR_DESC' => $information['DESCRIPCION'],
  1130. 'DEAR_CARA' => $information['CARACTERISTICAS'],
  1131. 'DEAR_COWE' => $information['COMPRA_WEB'],
  1132. 'DEAR_IDUN' => $information['TIPO_UNIDAD'],
  1133. 'DEAR_IMAG' => $jsonImages,
  1134. 'DEAR_NUPR' => $information['PROVEEDOR'],
  1135. 'DEAR_IDAR' => $numeroArticulo,
  1136. 'DEAR_NULI' => $requestData['NUMERO_LINEA'],
  1137. 'DEAR_USRE' => $usuario,
  1138. 'DEAR_FERE' => $currentDate,
  1139. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  1140. ]);
  1141. } catch (\Throwable $th) {
  1142. DB::rollBack();
  1143. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD023: Ocurrió un error al insertar los datos de la información del artículo.", $th->getMessage(), 500);
  1144. }
  1145. $arrDetails = $information['DETAILS'];
  1146. foreach ($arrDetails as $keyDetails => $details) {
  1147. try {
  1148. DB::table('S002V01TINAR')->insertGetId([
  1149. 'INAR_IDDE' => $numeroInformation,
  1150. 'INAR_CODI' => $details['CODIGO'],
  1151. 'INAR_MODE' => $details['MODELO'],
  1152. 'INAR_COMO' => $details['MONEDA'],
  1153. 'INAR_PREC' => $details['PRECIO'],
  1154. 'INAR_MOMI' => $details['MONTO_MINIMO'],
  1155. 'INAR_CARA' => $details['CARACTERISTICAS'],
  1156. 'INAR_NULI' => $requestData['NUMERO_LINEA'],
  1157. 'INAR_USRE' => $usuario,
  1158. 'INAR_FERE' => $currentDate,
  1159. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  1160. ]);
  1161. } catch (\Throwable $th) {
  1162. DB::rollBack();
  1163. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD024: Ocurrió un error al insertar los datos de los detalles del artículo.", $th->getMessage(), 500);
  1164. }
  1165. }
  1166. } else if ($information['ESTADO'] === 'Eliminado') {
  1167. try {
  1168. $validate = DB::table('S002V01TDEAR')->where('DEAR_IDDE', '=', $numeroInformation)->update([
  1169. 'DEAR_ESTA' => 'Eliminado',
  1170. 'DEAR_USMO' => $usuario,
  1171. 'DEAR_FEMO' => $currentDate,
  1172. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1173. ]);
  1174. } catch (\Throwable $th) {
  1175. DB::rollBack();
  1176. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD025: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1177. }
  1178. if (!$validate) {
  1179. DB::rollBack();
  1180. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD026: Ocurrió un error al modificar en la tabla.", [], 500);
  1181. }
  1182. }
  1183. }
  1184. DB::commit(); # Para guardar los cambios en la base de datos
  1185. return $this->responseController->makeResponse(false, "ÉXITO: Modificación Exitosa");
  1186. }
  1187. public function deleteArtitle(Request $request) {
  1188. $validator = Validator::make($request->all(), [
  1189. 'NUMERO_ARTITULO' => 'required|string',
  1190. 'NUMERO_LINEA' => 'required|string',
  1191. 'USUARIO' => 'required|string',
  1192. ]);
  1193. if ($validator->fails()) {
  1194. return $this->responseController->makeResponse(
  1195. true,
  1196. "ERR_ARTITLE_DEL000: Se encontraron uno o más errores.",
  1197. $this->responseController->makeErrors($validator->errors()->messages()),
  1198. 401
  1199. );
  1200. }
  1201. DB::beginTransaction();
  1202. $requestData = $request->all();
  1203. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($requestData['USUARIO'], $requestData['NUMERO_LINEA']);
  1204. if ($arrResponseCheckUser['error']) {
  1205. DB::rollBack();
  1206. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_DEL001:'.$arrResponseCheckUser['msg'], [], 401);
  1207. }
  1208. $usuario = $arrResponseCheckUser['response'];
  1209. try {
  1210. $artitleNumber = $this->encController->decrypt($requestData['NUMERO_ARTITULO']);
  1211. } catch (\Throwable $th) {
  1212. return $this->responseController->makeResponse(
  1213. true,
  1214. "ERR_ARTITLE_DEL002: Ocurrió un error al modificar el registro.",
  1215. $th->getMessage(),
  1216. 500
  1217. );
  1218. }
  1219. $now = $this->functionsController->now();
  1220. $currentDate = $now->toDateTimeString();
  1221. try {
  1222. $validateUpdate = DB::table('S002V01TARTI')
  1223. ->where('ARTI_IDAR', '=', $artitleNumber)
  1224. ->where('ARTI_NULI', '=', $requestData['NUMERO_LINEA'])
  1225. ->update([
  1226. 'ARTI_ESTA' => 'Eliminado',
  1227. 'ARTI_USMO' => $usuario,
  1228. 'ARTI_FEMO' => $currentDate,
  1229. 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1230. ]);
  1231. } catch (\Throwable $th) {
  1232. DB::rollBack();
  1233. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL003: Ocurrió un error al modificar el registro.", $th->getMessage(), 500);
  1234. }
  1235. if (!$validateUpdate) {
  1236. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL004: Ocurrió un error al modificar en la tabla.", [], 500);
  1237. }
  1238. try {
  1239. $arrDescription = DB::table('S002V01TDEAR')
  1240. ->where('DEAR_IDAR', '=', $artitleNumber)
  1241. ->get([ 'DEAR_IDDE AS NUMERO_DESCRIPCION' ]);
  1242. } catch (\Throwable $th) {
  1243. DB::rollBack();
  1244. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL005: Ocurrió un error al obtener los datos de la descripción del artículo", $th->getMessage(), 500);
  1245. }
  1246. foreach ($arrDescription as $keyDescription => $description) {
  1247. $numeroDescripcion = $description->NUMERO_DESCRIPCION;
  1248. try {
  1249. $validateUpdate = DB::table('S002V01TDEAR')
  1250. ->where('DEAR_IDDE', '=', $numeroDescripcion)
  1251. ->where('DEAR_NULI', '=', $requestData['NUMERO_LINEA'])
  1252. ->update([
  1253. 'DEAR_ESTA' => 'Eliminado',
  1254. 'DEAR_USMO' => $usuario,
  1255. 'DEAR_FEMO' => $currentDate,
  1256. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1257. ]);
  1258. } catch (\Throwable $th) {
  1259. DB::rollBack();
  1260. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL007: Ocurrió un error al modificar el registro.", $th->getMessage(), 500);
  1261. }
  1262. if (!$validateUpdate) {
  1263. DB::rollBack();
  1264. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL006: Ocurrió un error al modificar en la tabla.", [], 500);
  1265. }
  1266. try {
  1267. $validateUpdate = DB::table('S002V01TINAR')
  1268. ->where('INAR_IDDE', '=', $numeroDescripcion)
  1269. ->where('INAR_NULI', '=', $requestData['NUMERO_LINEA'])
  1270. ->update([
  1271. 'INAR_ESTA' => 'Eliminado',
  1272. 'INAR_USMO' => $usuario,
  1273. 'INAR_FEMO' => $currentDate,
  1274. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1275. ]);
  1276. } catch (\Throwable $th) {
  1277. DB::rollBack();
  1278. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL009: Ocurrió un error al modificar el registro.", $th->getMessage(), 500);
  1279. }
  1280. if (!$validateUpdate) {
  1281. DB::rollBack();
  1282. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL008: Ocurrió un error al modificar en la tabla.", [], 500);
  1283. }
  1284. }
  1285. DB::commit(); # Para guardar los cambios en la base de datos
  1286. return $this->responseController->makeResponse(false, "ÉXITO: Eliminación Exitosa");
  1287. }
  1288. public function generateArtitles(Request $request) {
  1289. $validator = Validator::make($request->all(), [
  1290. 'FILE_ZIP' => 'required',
  1291. 'NUMERO_LINEA' => 'required',
  1292. 'USUARIO' => 'required',
  1293. ]);
  1294. if ($validator->fails()) {
  1295. return $this->responseController->makeResponse(
  1296. true,
  1297. "ERR_ARTITLE_MOD000: Se encontraron uno o más errores.",
  1298. $this->responseController->makeErrors($validator->errors()->messages()),
  1299. 401
  1300. );
  1301. }
  1302. }
  1303. public function getArtitleByInformation($information, $user, $line) {
  1304. try {
  1305. $objInformation = (array) DB::table('S002V01TINAR')
  1306. ->where('INAR_IDIN', '=', $information)
  1307. ->where('INAR_ESTA', '=', 'Activo')
  1308. ->where('DEAR_ESTA', '=', 'Activo')
  1309. ->where('ARTI_ESTA', '=', 'Activo')
  1310. ->where('FAMI_ESTA', '=', 'Activo')
  1311. ->where('SUBF_ESTA', '=', 'Activo')
  1312. ->where('UNID_ESTA', '=', 'Activo')
  1313. ->where('PROV_ESTA', '=', 'Activo')
  1314. ->join('S002V01TDEAR', 'DEAR_IDDE', '=', 'INAR_IDDE')
  1315. ->join('S002V01TARTI', 'ARTI_IDAR', '=', 'DEAR_IDAR')
  1316. ->join('S002V01TFAMI', 'FAMI_COFA', '=', 'ARTI_COFA')
  1317. ->join('S002V01TSUBF', 'SUBF_COSU', '=', 'ARTI_COSU')
  1318. ->join('S002V01TUNID', 'UNID_IDUN', '=', 'DEAR_IDUN')
  1319. ->join('S002V01TPROV', 'PROV_NUPR', '=', 'DEAR_NUPR')
  1320. ->join('S002V01TCAMO', 'CAMO_COMO', '=', 'INAR_COMO')
  1321. ->first([
  1322. 'INAR_IDIN', // Identificador de Información del artículo
  1323. 'INAR_CODI', // Código del artículo
  1324. 'INAR_MODE', // Modelo del artículo
  1325. DB::raw('CONCAT("(", CAMO_COMO, ") ", CAMO_DESC) AS CAMO_COMO'),
  1326. 'INAR_PREC', // Precio
  1327. 'INAR_CARA', // Características
  1328. 'DEAR_IDDE', // Identificador de la descripción del artículo
  1329. 'DEAR_DESC', // Descripción del artículo
  1330. 'DEAR_CARA', // Características del artículo
  1331. 'DEAR_COWE', // Compra web
  1332. 'DEAR_IMAG', // Imagen
  1333. 'DEAR_IDUN', // Identificador de la unidad
  1334. 'UNID_NOMB', // Nombre de la unidad
  1335. 'UNID_ACRO', // Acrónimo de la familia
  1336. 'DEAR_NUPR', // Número del proveedor
  1337. 'ARTI_IDAR', // Identificador del artículo
  1338. 'ARTI_COFA', // Identificador de la familia
  1339. 'FAMI_NOFA', // Nombre de la familia
  1340. 'ARTI_COSU', // Identificador de la subfamilia
  1341. 'SUBF_NOSU', // Nombre de la subfamilia
  1342. 'ARTI_CODI', // Código del artículo
  1343. 'ARTI_NOMB', // Nombre del artículo
  1344. 'PROV_NOCO', // Nombre comercial
  1345. 'PROV_NOMB', // Nombre del proveedor
  1346. 'PROV_APPA', // Apellido paterno del proveedor
  1347. 'PROV_APMA', // Apellido materno del proveedor
  1348. 'PROV_CORR', // Correo electrónico
  1349. 'PROV_LAD1', // Lada 1
  1350. 'PROV_TEL1', // Teléfono 1
  1351. 'PROV_LAD2', // Lada 2
  1352. 'PROV_TEL2', // Teléfono 2
  1353. 'PROV_XRFC', // R.F.C
  1354. 'PROV_XTAX', // TAX ID
  1355. 'PROV_TIPO', // Tipo
  1356. 'PROV_SIWE', // Sitio Web
  1357. 'PROV_MEPA', // Metodos de pago
  1358. ]);
  1359. } catch (\Throwable $th) {
  1360. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYINFORMATION000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  1361. }
  1362. $objInformation['DEAR_IMAG'] = json_decode($objInformation['DEAR_IMAG']);
  1363. $arrUrlImage = array();
  1364. foreach ($objInformation['DEAR_IMAG'] as $key => $imagen) {
  1365. $responseDocument = $this->documentManagementController->privateGetPublicDocumentURL($imagen, $user, $line);
  1366. if ($responseDocument['error']) {
  1367. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYINFORMATION001: Ocurrió un error al obtener la URL de la imágen.", [], 500);
  1368. }
  1369. $arrUrlImage[] = $responseDocument['response']['public_uri'];
  1370. }
  1371. $objInformation['DEAR_IMAG'] = $arrUrlImage;
  1372. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $objInformation);
  1373. }
  1374. }