ArtitleController.php 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500
  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. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $getArtitle);
  384. }
  385. public function getArtitlesByProvider($artitle, $provider, $user, $line) {
  386. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
  387. if ($arrResponseCheckUser['error']) {
  388. DB::rollBack();
  389. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_GETBYPROVIDER000:'.$arrResponseCheckUser['msg'], [], 401);
  390. }
  391. try {
  392. $idArtitle = $this->encController->decrypt($artitle);
  393. } catch (\Throwable $th) {
  394. return $this->responseController->makeResponse(
  395. true,
  396. "ERR_ARTITLE_GETBYPROVIDER001: No se pudo realizar la consulta a la base.",
  397. $th->getMessage(),
  398. 500
  399. );
  400. }
  401. try {
  402. $idProvider = $this->encController->decrypt($provider);
  403. } catch (\Throwable $th) {
  404. return $this->responseController->makeResponse(
  405. true,
  406. "ERR_ARTITLE_GETBYPROVIDER002: No se pudo realizar la consulta a la base.",
  407. $th->getMessage(),
  408. 500
  409. );
  410. }
  411. try {
  412. $objArtitle = (array) DB::table('S002V01TDEAR')
  413. ->where("ARTI_NULI", "=", $line)
  414. ->where("DEAR_IDDE", "=", $idArtitle)
  415. ->where("DEAR_NUPR", "=", $idProvider)
  416. ->join("S002V01TARTI", "ARTI_IDAR", "=", "DEAR_IDAR")
  417. ->join("S002V01TFAMI", "ARTI_COFA", "=", "FAMI_COFA")
  418. ->join("S002V01TSUBF", "ARTI_COSU", "=", "SUBF_COSU")
  419. ->join("S002V01TPROV", "DEAR_NUPR", "=", "PROV_NUPR")
  420. ->join("S002V01TUNID", "DEAR_IDUN", "=", "UNID_IDUN")
  421. ->first([
  422. "DEAR_IDDE AS ID_DESC_ARTI",
  423. "ARTI_IDAR AS ID_ARTICULO",
  424. "ARTI_NOMB AS MODELO",
  425. "FAMI_COFA AS ID_FAMILIA",
  426. "FAMI_NOFA AS FAMILIA",
  427. "SUBF_COSU AS ID_SUBFAMILIA",
  428. "SUBF_NOSU AS SUBFAMILIA",
  429. "DEAR_DESC AS DESCRIPCION",
  430. "DEAR_CARA AS CARACTERISTICAS",
  431. "DEAR_COWE AS COMPRA_WEB",
  432. "UNID_IDUN AS ID_UNIDAD",
  433. "UNID_NOMB AS UNIDAD",
  434. "DEAR_IMAG AS URL_IMAGEN",
  435. "PROV_NUPR AS ID_PROVEEDOR",
  436. "PROV_NOCO AS PROVEEDOR",
  437. ]);
  438. } catch (\Throwable $th) {
  439. return $this->responseController->makeResponse(
  440. true,
  441. "ERR_ARTITLE_GETBYPROVIDER003: No se pudo realizar la consulta a la base.",
  442. $th->getMessage(),
  443. 500
  444. );
  445. }
  446. if ( empty($objArtitle) ) {
  447. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYPROVIDER004: No se encontró el resultado deseado.", [], 500);
  448. }
  449. try {
  450. $objArtitle['URL_IMAGEN'] = json_decode($objArtitle['URL_IMAGEN']);
  451. $arrUrlImage = array();
  452. foreach ($objArtitle['URL_IMAGEN'] as $key => $encImage) {
  453. $responseDocument = $this->documentManagementController->privateGetPublicDocumentURL($encImage, $user, $line);
  454. if ($responseDocument['error']) {
  455. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYPROVIDER005: Ocurrió un error al obtener la URL de la imágen.", [], 500);
  456. }
  457. $arrUrlImage[] = $responseDocument['response']['public_uri'];
  458. }
  459. $objArtitle['URL_IMAGEN'] = $arrUrlImage;
  460. } catch (\Throwable $th) {
  461. return $this->responseController->makeResponse(
  462. true,
  463. "ERR_ARTITLE_GETBYPROVIDER006: Ocurrió un error al obtner las imagenes de los artículos",
  464. $th->getMessage(),
  465. 500
  466. );
  467. }
  468. try {
  469. $arrInformation = DB::table('S002V01TINAR')
  470. ->where('INAR_ESTA', '=', 'Activo')
  471. ->where('INAR_NULI', '=', $line)
  472. ->where('INAR_IDDE', '=', $objArtitle['ID_DESC_ARTI'])
  473. ->join('S002V01TCAMO', 'CAMO_COMO', '=', 'INAR_COMO')
  474. ->get([
  475. 'INAR_IDIN AS NUMERO_INFORMACION',
  476. 'INAR_CODI AS CODIGO',
  477. 'INAR_MODE AS MODELO',
  478. 'CAMO_COMO AS MONEDA',
  479. 'CAMO_DESC AS MONEDA_DESCRIPCION',
  480. 'INAR_PREC AS PRECIO',
  481. 'INAR_MOMI AS MONTO_MINIMO',
  482. 'INAR_CARA AS CARACTERISTICAS',
  483. ]);
  484. } catch (\Throwable $th) {
  485. return $this->responseController->makeResponse(
  486. true,
  487. "ERR_ARTITLE_GETBYPROVIDER007: No se pudo realizar la consulta a la base.",
  488. $th->getMessage(),
  489. 500
  490. );
  491. }
  492. $objArtitle['INFO_PRODUCTO'] = json_encode($arrInformation);
  493. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $objArtitle);
  494. }
  495. public function getArtitleById($encIdArtitle, $user, $line) {
  496. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
  497. if ($arrResponseCheckUser['error']) {
  498. DB::rollBack();
  499. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_GETBYID000:'.$arrResponseCheckUser['msg'], [], 401);
  500. }
  501. try {
  502. $idArtitle = $this->encController->decrypt($encIdArtitle);
  503. } catch (\Throwable $th) {
  504. return $this->responseController->makeResponse(
  505. true,
  506. "ERR_ARTITLE_GETBYID001: Ocurrió un error al obtener el artículo.",
  507. $th->getMessage(),
  508. 500
  509. );
  510. }
  511. try {
  512. $arrArtitle = DB::table('S002V01TARTI')
  513. ->where('ARTI_IDAR', '=', $idArtitle)
  514. ->where('ARTI_ESTA', '=', 'Activo')
  515. ->where('ARTI_NULI', '=', $line)
  516. ->join("S002V01TFAMI", "ARTI_COFA", "=", "FAMI_COFA")
  517. ->join("S002V01TSUBF", "ARTI_COSU", "=", "SUBF_COSU")
  518. ->first([
  519. 'ARTI_IDAR AS NUMERO_ARTICULO',
  520. 'ARTI_CODI AS CODIGO',
  521. "FAMI_COFA AS ID_FAMILIA",
  522. "FAMI_NOFA AS FAMILIA",
  523. "SUBF_COSU AS ID_SUBFAMILIA",
  524. "SUBF_NOSU AS SUBFAMILIA",
  525. 'ARTI_NOMB AS ARTICULO',
  526. ]);
  527. } catch (\Throwable $th) {
  528. return $this->responseController->makeResponse(
  529. true,
  530. "ERR_ARTITLE_GETBYID002: No se pudo realizar la consulta a la base.",
  531. $th->getMessage(),
  532. 500
  533. );
  534. }
  535. try {
  536. $arrDescription = DB::table('S002V01TDEAR')
  537. ->where('DEAR_IDAR', '=', $idArtitle)
  538. ->where('DEAR_ESTA', '=', 'Activo')
  539. ->where('DEAR_NULI', '=', $line)
  540. ->join("S002V01TUNID", "DEAR_IDUN", "=", "UNID_IDUN")
  541. ->get([
  542. 'DEAR_IDDE AS ID_DESCRIPCION',
  543. 'DEAR_DESC AS DESCRIPCION',
  544. 'DEAR_CARA AS CARACTERISTICAS',
  545. 'DEAR_COWE AS COMPRA_WEB',
  546. 'DEAR_IDUN AS TIPO_UNIDAD',
  547. 'DEAR_IMAG AS IMAGEN',
  548. 'DEAR_NUPR AS PROVEEDOR',
  549. 'DEAR_ESTA AS ESTADO',
  550. ]);
  551. } catch (\Throwable $th) {
  552. return $this->responseController->makeResponse(
  553. true,
  554. "ERR_ARTITLE_GETBYID003: No se pudo realizar la consulta a la base.",
  555. $th->getMessage(),
  556. 500
  557. );
  558. }
  559. if ( empty($arrDescription) ) {
  560. return $this->responseController->makeResponse(
  561. true,
  562. "ERR_ARTITLE_GETBYID004: No se encontró ninguna descripción.",
  563. [],
  564. 500
  565. );
  566. }
  567. // Se obtienen las URL de las imagenes de los artículos
  568. try {
  569. foreach ($arrDescription as $description) {
  570. $arrImagen = json_decode($description->IMAGEN);
  571. $arrUrlImage = array();
  572. foreach ($arrImagen as $key => $imagen) {
  573. $responseDocument = $this->documentManagementController->privateGetPublicDocumentURL($imagen, $user, $line);
  574. if ($responseDocument['error']) {
  575. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYID005: Ocurrió un error al obtener la URL de la imágen.", [], 500);
  576. }
  577. $arrUrlImage[] = $responseDocument['response']['public_uri'];
  578. }
  579. $description->IMAGEN = $arrUrlImage;
  580. }
  581. } catch (\Throwable $th) {
  582. return $this->responseController->makeResponse(
  583. true,
  584. "ERR_ARTITLE_GETBYID006: Ocurrió un error al obtener las imágenes de los artículos.",
  585. [],
  586. 500
  587. );
  588. }
  589. foreach ($arrDescription as $description) {
  590. try {
  591. $arrDetails = DB::table('S002V01TINAR')
  592. ->where('INAR_IDDE', '=', $description->ID_DESCRIPCION)
  593. ->where('INAR_ESTA', '=', 'Activo')
  594. ->where('INAR_NULI', '=', $line)
  595. ->join('S002V01TCAMO', 'CAMO_COMO', '=', 'INAR_COMO')
  596. ->get([
  597. 'INAR_IDIN AS NUMERO_DETALLE',
  598. 'INAR_CODI AS CODIGO',
  599. 'INAR_MODE AS MODELO',
  600. DB::raw('CONCAT("(", CAMO_COMO, ") ", CAMO_DESC) AS MONEDA'),
  601. 'INAR_PREC AS PRECIO',
  602. 'INAR_MOMI AS MONTO_MINIMO',
  603. // 'INAR_CANT AS CANTIDAD',
  604. 'INAR_CARA AS CARACTERISTICAS',
  605. 'INAR_ESTA AS ESTADO',
  606. ]);
  607. } catch (\Throwable $th) {
  608. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYID007: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  609. }
  610. $description->DETALLES = $arrDetails;
  611. try {
  612. $objProdiver = DB::table('S002V01TPROV')
  613. ->where('PROV_NUPR', '=', $description->PROVEEDOR)
  614. ->where('PROV_ESTA', '=', 'Activo')
  615. ->where('PROV_NULI', '=', $line)
  616. ->first([
  617. 'PROV_NUPR',
  618. 'PROV_NOCO',
  619. 'PROV_NOMB',
  620. 'PROV_APPA',
  621. 'PROV_APMA',
  622. 'PROV_CORR',
  623. 'PROV_LAD1',
  624. 'PROV_TEL1',
  625. 'PROV_LAD2',
  626. 'PROV_TEL2',
  627. 'PROV_XRFC',
  628. 'PROV_XTAX',
  629. 'PROV_CRFI',
  630. 'PROV_TIPO',
  631. 'PROV_SIWE',
  632. 'PROV_MEPA',
  633. 'PROV_USRE',
  634. 'PROV_FERE',
  635. 'PROV_USMO',
  636. 'PROV_FEMO',
  637. ]);
  638. $description->PROVEEDOR = $objProdiver;
  639. } catch (\Throwable $th) {
  640. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYID008: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  641. }
  642. }
  643. $arrArtitle->INFORMACION = $arrDescription;
  644. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrArtitle);
  645. }
  646. public function getAllArtitles($user, $line) {
  647. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
  648. if ($arrResponseCheckUser['error']) {
  649. DB::rollBack();
  650. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_GETALL000:'.$arrResponseCheckUser['msg'], [], 401);
  651. }
  652. try {
  653. $arrArtitle = DB::table('S002V01TARTI')
  654. ->where("ARTI_NULI", "=", $line)
  655. ->join("S002V01TFAMI", "ARTI_COFA", "=", "FAMI_COFA")
  656. ->join("S002V01TSUBF", "ARTI_COSU", "=", "SUBF_COSU")
  657. ->get([
  658. "ARTI_IDAR AS ID_ARTICULO",
  659. "ARTI_NOMB AS MODELO",
  660. "FAMI_COFA AS ID_FAMILIA",
  661. "FAMI_NOFA AS FAMILIA",
  662. "SUBF_COSU AS ID_SUBFAMILIA",
  663. "SUBF_NOSU AS SUBFAMILIA",
  664. "ARTI_ESTA AS ESTADO",
  665. "ARTI_USRE AS USUARIO_REGISTRA",
  666. "ARTI_FERE AS FECHA_REGISTRA",
  667. "ARTI_USMO AS USUARIO_MODIFICA",
  668. "ARTI_FEMO AS FECHA_MODIFICA",
  669. ]);
  670. } catch (\Throwable $th) {
  671. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETALL001: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  672. }
  673. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrArtitle);
  674. }
  675. public function registerArtitles(Request $request) {
  676. $validator = Validator::make($request->all(), [
  677. 'CODIGO' => 'required|string',
  678. 'ARTICULO' => 'required|string',
  679. 'FAMILIA' => 'required|string',
  680. 'SUBFAMILIA' => 'required|string',
  681. 'INFORMATION' => 'required|array',
  682. 'USUARIO' => 'required|string',
  683. 'NUMERO_LINEA' => 'required|string',
  684. ]);
  685. if ($validator->fails()) {
  686. return $this->responseController->makeResponse(
  687. true,
  688. "ERR_ARTITLE_REG000: Se encontraron uno o más errores.",
  689. $this->responseController->makeErrors($validator->errors()->messages()),
  690. 401
  691. );
  692. }
  693. DB::beginTransaction();
  694. $requestData = $request->all();
  695. foreach ($requestData['INFORMATION'] as $information) {
  696. $validator = Validator::make($information, [
  697. 'NO' => 'required|string',
  698. 'IMAGEN' => 'required|array',
  699. 'DESCRIPCION' => 'required|string',
  700. // 'CARACTERISTICAS' => '|string',
  701. 'TIPO_UNIDAD' => 'required|integer',
  702. 'PROVEEDOR' => 'required|string',
  703. 'COMPRA_WEB' => 'required|boolean',
  704. 'ESTADO' => 'required|string',
  705. 'DETAILS' => 'required|array',
  706. ]);
  707. if ($validator->fails()) {
  708. return $this->responseController->makeResponse(
  709. true,
  710. "ERR_ARTITLE_REG001: Se encontraron uno o más errores.",
  711. $this->responseController->makeErrors($validator->errors()->messages()),
  712. 401
  713. );
  714. }
  715. foreach ($information['DETAILS'] as $details) {
  716. $validator = Validator::make($details, [
  717. 'NO' => 'required|string',
  718. 'CODIGO' => 'required|string',
  719. 'MODELO' => 'required|string',
  720. 'MONEDA' => 'required|string',
  721. 'PRECIO' => 'required|string',
  722. 'MONTO_MINIMO' => 'required|string',
  723. 'ESTADO' => 'required|string',
  724. 'CARACTERISTICAS' => 'required|string',
  725. ]);
  726. if ($validator->fails()) {
  727. return $this->responseController->makeResponse(
  728. true,
  729. "ERR_ARTITLE_REG002: Se encontraron uno o más errores.",
  730. $this->responseController->makeErrors($validator->errors()->messages()),
  731. 401
  732. );
  733. }
  734. }
  735. }
  736. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($requestData['USUARIO'], $requestData['NUMERO_LINEA']);
  737. if ($arrResponseCheckUser['error']) {
  738. DB::rollBack();
  739. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG003:'.$arrResponseCheckUser['msg'], [], 401);
  740. }
  741. $usuario = $arrResponseCheckUser['response'];
  742. $now = $this->functionsController->now();
  743. $currentDate = $now->toDateTimeString();
  744. try {
  745. $idArtitle = DB::table('S002V01TARTI')->insertGetId([
  746. 'ARTI_CODI' => $requestData['CODIGO'],
  747. 'ARTI_COFA' => $requestData['FAMILIA'],
  748. 'ARTI_COSU' => $requestData['SUBFAMILIA'],
  749. 'ARTI_NOMB' => $requestData['ARTICULO'],
  750. 'ARTI_NULI' => $requestData['NUMERO_LINEA'],
  751. 'ARTI_USRE' => $usuario,
  752. 'ARTI_FERE' => $currentDate,
  753. 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  754. ]);
  755. } catch (\Throwable $th) {
  756. DB::rollBack();
  757. return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG004: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  758. }
  759. foreach ($requestData['INFORMATION'] as $keyInformation => $information) {
  760. try {
  761. $arrCodeImages = array();
  762. foreach ($information['IMAGEN'] as $key => $encIdFile) {
  763. $idFile = $this->encController->decrypt($encIdFile);
  764. $tempFile = DB::table('S002V01TARTE')->where([
  765. ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
  766. ['ARTE_IDAR', '=', $idFile],
  767. ])->first();
  768. if(is_null($tempFile)){
  769. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG005: El archivo consultado no está registrado', [], 404);
  770. }else if($tempFile->ARTE_ESTA == 'Eliminado'){
  771. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG006: El archivo consultado está eliminado', [], 404);
  772. }
  773. $fileResponse = $this->documentManagementController->moveFinalFile(
  774. intval($requestData['NUMERO_LINEA']),
  775. 'GEAD',
  776. 'FO',
  777. $tempFile,
  778. $usuario,
  779. );
  780. if(!$fileResponse[0]){
  781. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG007: '.$fileResponse[1], [], 400);
  782. }
  783. $arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
  784. }
  785. $jsonImages = json_encode($arrCodeImages);
  786. } catch (\Throwable $th) {
  787. DB::rollBack();
  788. return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG008: Ocurrió un error al obtener la URL pública de las imágenes.", $th->getMessage(), 500);
  789. }
  790. try {
  791. $idDescription = DB::table('S002V01TDEAR')->insertGetId([
  792. 'DEAR_DESC' => $information['DESCRIPCION'],
  793. 'DEAR_CARA' => $information['CARACTERISTICAS'],
  794. 'DEAR_COWE' => $information['COMPRA_WEB'],
  795. 'DEAR_IDUN' => $information['TIPO_UNIDAD'],
  796. 'DEAR_IMAG' => $jsonImages,
  797. 'DEAR_NUPR' => $information['PROVEEDOR'],
  798. 'DEAR_IDAR' => $idArtitle,
  799. 'DEAR_NULI' => $requestData['NUMERO_LINEA'],
  800. 'DEAR_USRE' => $usuario,
  801. 'DEAR_FERE' => $currentDate,
  802. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  803. ]);
  804. } catch (\Throwable $th) {
  805. DB::rollBack();
  806. 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);
  807. }
  808. $arrDetails = $information['DETAILS'];
  809. foreach ($arrDetails as $keyDetails => $details) {
  810. $insertDetails = [
  811. 'INAR_IDDE' => $idDescription,
  812. 'INAR_CODI' => $details['CODIGO'],
  813. 'INAR_MODE' => $details['MODELO'],
  814. 'INAR_COMO' => $details['MONEDA'],
  815. 'INAR_PREC' => $details['PRECIO'],
  816. 'INAR_MOMI' => $details['MONTO_MINIMO'],
  817. 'INAR_CARA' => $details['CARACTERISTICAS'],
  818. 'INAR_NULI' => $requestData['NUMERO_LINEA'],
  819. 'INAR_USRE' => $usuario,
  820. 'INAR_FERE' => $currentDate,
  821. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  822. ];
  823. try {
  824. $validateDetails = DB::table('S002V01TINAR')->insert($insertDetails);
  825. } catch (\Throwable $th) {
  826. DB::rollBack();
  827. return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG010: Ocurrió un error al insertar los datos de los detalles del artículo.", $th->getMessage(), 500);
  828. }
  829. if (!$validateDetails) {
  830. DB::rollBack();
  831. return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG011: No se pudo insertar los datos de los detalles.", [], 500);
  832. }
  833. }
  834. }
  835. DB::commit();
  836. return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
  837. }
  838. public function updateArtitles(Request $request) {
  839. $validator = Validator::make($request->all(), [
  840. 'NO' => 'required|string',
  841. 'CODIGO' => 'required|string',
  842. 'ARTICULO' => 'required|string',
  843. 'FAMILIA' => 'required|string',
  844. 'SUBFAMILIA' => 'required|string',
  845. 'USUARIO' => 'required|string',
  846. 'NUMERO_LINEA' => 'required|string',
  847. 'INFORMATION' => 'required',
  848. ]);
  849. if ($validator->fails()) {
  850. return $this->responseController->makeResponse(
  851. true,
  852. "ERR_ARTITLE_MOD000: Se encontraron uno o más errores.",
  853. $this->responseController->makeErrors($validator->errors()->messages()),
  854. 401
  855. );
  856. }
  857. DB::beginTransaction(); # Para impedir que las actualizaciones queden a incompletas
  858. $requestData = $request->all();
  859. foreach ($requestData['INFORMATION'] as $information) {
  860. $validator = Validator::make($information, [
  861. 'NO' => 'required|integer',
  862. 'IMAGEN' => 'required|array',
  863. 'DESCRIPCION' => 'required|string',
  864. // 'CARACTERISTICAS' => '|string',
  865. 'TIPO_UNIDAD' => 'required|integer',
  866. 'PROVEEDOR' => 'required|string',
  867. 'COMPRA_WEB' => 'required|boolean',
  868. 'ESTADO' => 'required|string',
  869. 'DETAILS' => 'required|array',
  870. ]);
  871. if ($validator->fails()) {
  872. return $this->responseController->makeResponse(
  873. true,
  874. "ERR_ARTITLE_MOD001: Se encontraron uno o más errores.",
  875. $this->responseController->makeErrors($validator->errors()->messages()),
  876. 401
  877. );
  878. }
  879. foreach ($information['DETAILS'] as $details) {
  880. $validator = Validator::make($details, [
  881. 'NO' => 'required|string',
  882. 'CODIGO' => 'required|string',
  883. 'MODELO' => 'required|string',
  884. 'MONEDA' => 'required|string',
  885. 'PRECIO' => 'required|string',
  886. 'MONTO_MINIMO' => 'required|string',
  887. 'ESTADO' => 'required|string',
  888. 'CARACTERISTICAS' => 'required|string',
  889. ]);
  890. if ($validator->fails()) {
  891. return $this->responseController->makeResponse(
  892. true,
  893. "ERR_ARTITLE_MOD002: Se encontraron uno o más errores.",
  894. $this->responseController->makeErrors($validator->errors()->messages()),
  895. 401
  896. );
  897. }
  898. }
  899. foreach ($information['IMAGEN'] as $key => $imagen) {
  900. if (gettype($imagen) != 'string') {
  901. return $this->responseController->makeResponse(
  902. true,
  903. "ERR_ARTITLE_MOD003: Se encontraron uno o más errores.",
  904. "Se se obtuvieron los ID de los archivos.",
  905. 401
  906. );
  907. }
  908. }
  909. }
  910. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($requestData['USUARIO'], $requestData['NUMERO_LINEA']);
  911. if ($arrResponseCheckUser['error']) {
  912. DB::rollBack();
  913. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD004:'.$arrResponseCheckUser['msg'], [], 401);
  914. }
  915. $usuario = $arrResponseCheckUser['response'];
  916. $now = $this->functionsController->now();
  917. $currentDate = $now->toDateTimeString();
  918. $numeroArticulo = $requestData['NO'];
  919. try {
  920. $validateUpdate = DB::table('S002V01TARTI')
  921. ->where('ARTI_IDAR', '=', $numeroArticulo)
  922. ->where('ARTI_NULI', '=', $requestData['NUMERO_LINEA'])
  923. ->update([
  924. 'ARTI_CODI' => $requestData['CODIGO'],
  925. 'ARTI_COFA' => $requestData['FAMILIA'],
  926. 'ARTI_COSU' => $requestData['SUBFAMILIA'],
  927. 'ARTI_NOMB' => $requestData['ARTICULO'],
  928. 'ARTI_USMO' => $usuario,
  929. 'ARTI_FEMO' => $currentDate,
  930. 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  931. ]);
  932. } catch (\Throwable $th) {
  933. DB::rollBack();
  934. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD005: Ocurrió un error al modificar el registro.", $th->getMessage(), 500);
  935. }
  936. if (!$validateUpdate) {
  937. DB::rollBack();
  938. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD006: Ocurrió un error al modificar en la tabla.", [], 500);
  939. }
  940. $arrInformation = $requestData['INFORMATION'];
  941. foreach ($arrInformation as $keyInformation => $information) {
  942. // Número de ID de información
  943. $numeroInformation = $information['NO'];
  944. // Se verifica si la información ya está registrado o no
  945. if ($information['ESTADO'] === 'Modificado' || $information['ESTADO'] === 'Activo') {
  946. $arrCodeImages = array();
  947. foreach ($information['IMAGEN'] as $key => $encIdFile) {
  948. $idFile = $this->encController->decrypt($encIdFile);
  949. $arrCode = explode('=', $idFile);
  950. if ( count($arrCode) == 3 ) {
  951. $arrStrucuteCode = explode("-", $arrCode[0]);
  952. $nameCode = explode(".", $arrCode[2]);
  953. $validateImage = DB::table('S002V01TAFAL')->where([
  954. ['AFAL_NULI', '=', $requestData['NUMERO_LINEA']],
  955. ['AFAL_COMO', '=', $arrStrucuteCode['1']],
  956. ['AFAL_CLDO', '=', $arrStrucuteCode['2']],
  957. ['AFAL_NOAR', '=', $nameCode[0]],
  958. ['AFAL_EXTE', '=', $nameCode[1]],
  959. ])->orderBy('AFAL_NUVE', 'desc')->exists();
  960. if (!$validateImage) {
  961. DB::rollBack();
  962. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD007: : La imagen con el código $idFile no existe.", [], 500);
  963. }
  964. $arrCodeImages[] = $this->encController->encrypt($idFile);
  965. } else {
  966. $tempFile = DB::table('S002V01TARTE')->where([
  967. ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
  968. ['ARTE_IDAR', '=', $idFile],
  969. ])->first();
  970. if(is_null($tempFile)){
  971. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD008: El archivo consultado no está registrado', $idFile, 404);
  972. }else if($tempFile->ARTE_ESTA == 'Eliminado'){
  973. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD009: El archivo consultado está eliminado', $tempFile, 404);
  974. }
  975. $fileResponse = $this->documentManagementController->moveFinalFile(
  976. intval($requestData['NUMERO_LINEA']),
  977. 'GEAD',
  978. 'FO',
  979. $tempFile,
  980. $usuario,
  981. );
  982. if(!$fileResponse[0]){
  983. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD010: ".$fileResponse[1], [], 400);
  984. }
  985. $arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
  986. // $arrCodeImages[] = $fileResponse[1];
  987. }
  988. }
  989. $jsonImages = json_encode($arrCodeImages);
  990. try {
  991. $validate = DB::table('S002V01TDEAR')->where('DEAR_IDDE', '=', $numeroInformation)->update([
  992. 'DEAR_DESC' => $information['DESCRIPCION'],
  993. 'DEAR_CARA' => $information['CARACTERISTICAS'],
  994. 'DEAR_COWE' => $information['COMPRA_WEB'],
  995. 'DEAR_IDUN' => $information['TIPO_UNIDAD'],
  996. 'DEAR_IMAG' => $jsonImages,
  997. 'DEAR_NUPR' => $information['PROVEEDOR'],
  998. 'DEAR_USMO' => $usuario,
  999. 'DEAR_FEMO' => $currentDate,
  1000. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1001. ]);
  1002. } catch (\Throwable $th) {
  1003. DB::rollBack();
  1004. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD011: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1005. }
  1006. if (!$validate) {
  1007. DB::rollBack();
  1008. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD012: Ocurrió un error al modificar en la tabla.", [], 500);
  1009. }
  1010. $arrDetails = $information['DETAILS'];
  1011. foreach ($arrDetails as $keyDetails => $details) {
  1012. $numeroDetails = $details['NO'];
  1013. if ( $details['ESTADO'] === 'Modificado' || $details['ESTADO'] === 'Activo') {
  1014. try {
  1015. $validate = DB::table('S002V01TINAR')->where('INAR_IDIN', '=', $numeroDetails)->update([
  1016. 'INAR_CODI' => $details['CODIGO'],
  1017. 'INAR_MODE' => $details['MODELO'],
  1018. 'INAR_COMO' => $details['MONEDA'],
  1019. 'INAR_PREC' => $details['PRECIO'],
  1020. 'INAR_MOMI' => $details['MONTO_MINIMO'],
  1021. // 'INAR_CANT' => $details['CANTIDAD'],
  1022. 'INAR_CARA' => $details['CARACTERISTICAS'],
  1023. 'INAR_USMO' => $usuario,
  1024. 'INAR_FEMO' => $currentDate,
  1025. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1026. ]);
  1027. } catch (\Throwable $th) {
  1028. DB::rollBack();
  1029. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD013: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1030. }
  1031. if (!$validate) {
  1032. DB::rollBack();
  1033. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD014: Ocurrió un error al modificar en la tabla.", [], 500);
  1034. }
  1035. } else if ($details['ESTADO'] === 'Nuevo') {
  1036. try {
  1037. $validate = DB::table('S002V01TINAR')->insertGetId([
  1038. 'INAR_IDDE' => $numeroInformation,
  1039. 'INAR_CODI' => $details['CODIGO'],
  1040. 'INAR_MODE' => $details['MODELO'],
  1041. 'INAR_COMO' => $details['MONEDA'],
  1042. 'INAR_PREC' => $details['PRECIO'],
  1043. 'INAR_MOMI' => $details['MONTO_MINIMO'],
  1044. 'INAR_CARA' => $details['CARACTERISTICAS'],
  1045. 'INAR_NULI' => $requestData['NUMERO_LINEA'],
  1046. 'INAR_USRE' => $usuario,
  1047. 'INAR_FERE' => $currentDate,
  1048. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  1049. ]);
  1050. } catch (\Throwable $th) {
  1051. DB::rollBack();
  1052. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD015: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1053. }
  1054. if (!$validate) {
  1055. DB::rollBack();
  1056. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD016: Ocurrió un error al modificar en la tabla.", [], 500);
  1057. }
  1058. } else if ($details['ESTADO'] === 'Eliminado') {
  1059. try {
  1060. $validate = DB::table('S002V01TINAR')->where('INAR_IDIN', '=', $numeroDetails)->update([
  1061. 'INAR_ESTA' => 'Eliminado',
  1062. 'INAR_USMO' => $usuario,
  1063. 'INAR_FEMO' => $currentDate,
  1064. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1065. ]);
  1066. } catch (\Throwable $th) {
  1067. DB::rollBack();
  1068. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD017: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1069. }
  1070. if (!$validate) {
  1071. DB::rollBack();
  1072. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD018: Ocurrió un error al modificar en la tabla.", [], 500);
  1073. }
  1074. }
  1075. }
  1076. } else if ($information['ESTADO'] === 'Nuevo') {
  1077. $arrCodeImages = array();
  1078. foreach ($information['IMAGEN'] as $key => $encIdFile) {
  1079. $idFile = $this->encController->decrypt($encIdFile);
  1080. $arrCode = explode('=', $idFile);
  1081. if ( count($arrCode) == 3 ) {
  1082. $arrStrucuteCode = explode("-", $arrCode[0]);
  1083. $nameCode = explode(".", $arrCode[2]);
  1084. $validateImage = DB::table('S002V01TAFAL')->where([
  1085. ['AFAL_NULI', '=', $requestData['NUMERO_LINEA']],
  1086. ['AFAL_COMO', '=', $arrStrucuteCode['1']],
  1087. ['AFAL_CLDO', '=', $arrStrucuteCode['2']],
  1088. ['AFAL_NOAR', '=', $nameCode[0]],
  1089. ['AFAL_EXTE', '=', $nameCode[1]],
  1090. ])->orderBy('AFAL_NUVE', 'desc')->exists();
  1091. if (!$validateImage) {
  1092. DB::rollBack();
  1093. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD019: La imagen con el código $idFile no existe.", [], 500);
  1094. }
  1095. $arrCodeImages[] = $this->encController->encrypt($idFile);
  1096. } else {
  1097. $tempFile = DB::table('S002V01TARTE')->where([
  1098. ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
  1099. ['ARTE_IDAR', '=', $idFile],
  1100. ])->first();
  1101. if(is_null($tempFile)){
  1102. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD020: El archivo consultado no está registrado', [], 404);
  1103. }else if($tempFile->ARTE_ESTA == 'Eliminado'){
  1104. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD021: El archivo consultado está eliminado', [], 404);
  1105. }
  1106. $fileResponse = $this->documentManagementController->moveFinalFile(
  1107. intval($requestData['NUMERO_LINEA']),
  1108. 'GEAD',
  1109. 'FO',
  1110. $tempFile,
  1111. $usuario,
  1112. );
  1113. if(!$fileResponse[0]){
  1114. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_MOD022: '.$fileResponse[1], [], 400);
  1115. }
  1116. $arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
  1117. }
  1118. }
  1119. $jsonImages = json_encode($arrCodeImages);
  1120. try {
  1121. $numeroInformation = DB::table('S002V01TDEAR')->insertGetId([
  1122. 'DEAR_DESC' => $information['DESCRIPCION'],
  1123. 'DEAR_CARA' => $information['CARACTERISTICAS'],
  1124. 'DEAR_COWE' => $information['COMPRA_WEB'],
  1125. 'DEAR_IDUN' => $information['TIPO_UNIDAD'],
  1126. 'DEAR_IMAG' => $jsonImages,
  1127. 'DEAR_NUPR' => $information['PROVEEDOR'],
  1128. 'DEAR_IDAR' => $numeroArticulo,
  1129. 'DEAR_NULI' => $requestData['NUMERO_LINEA'],
  1130. 'DEAR_USRE' => $usuario,
  1131. 'DEAR_FERE' => $currentDate,
  1132. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  1133. ]);
  1134. } catch (\Throwable $th) {
  1135. DB::rollBack();
  1136. 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);
  1137. }
  1138. $arrDetails = $information['DETAILS'];
  1139. foreach ($arrDetails as $keyDetails => $details) {
  1140. try {
  1141. DB::table('S002V01TINAR')->insertGetId([
  1142. 'INAR_IDDE' => $numeroInformation,
  1143. 'INAR_CODI' => $details['CODIGO'],
  1144. 'INAR_MODE' => $details['MODELO'],
  1145. 'INAR_COMO' => $details['MONEDA'],
  1146. 'INAR_PREC' => $details['PRECIO'],
  1147. 'INAR_MOMI' => $details['MONTO_MINIMO'],
  1148. 'INAR_CARA' => $details['CARACTERISTICAS'],
  1149. 'INAR_NULI' => $requestData['NUMERO_LINEA'],
  1150. 'INAR_USRE' => $usuario,
  1151. 'INAR_FERE' => $currentDate,
  1152. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
  1153. ]);
  1154. } catch (\Throwable $th) {
  1155. DB::rollBack();
  1156. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD024: Ocurrió un error al insertar los datos de los detalles del artículo.", $th->getMessage(), 500);
  1157. }
  1158. }
  1159. } else if ($information['ESTADO'] === 'Eliminado') {
  1160. try {
  1161. $validate = DB::table('S002V01TDEAR')->where('DEAR_IDDE', '=', $numeroInformation)->update([
  1162. 'DEAR_ESTA' => 'Eliminado',
  1163. 'DEAR_USMO' => $usuario,
  1164. 'DEAR_FEMO' => $currentDate,
  1165. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1166. ]);
  1167. } catch (\Throwable $th) {
  1168. DB::rollBack();
  1169. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD025: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
  1170. }
  1171. if (!$validate) {
  1172. DB::rollBack();
  1173. return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD026: Ocurrió un error al modificar en la tabla.", [], 500);
  1174. }
  1175. }
  1176. }
  1177. DB::commit(); # Para guardar los cambios en la base de datos
  1178. return $this->responseController->makeResponse(false, "ÉXITO: Modificación Exitosa");
  1179. }
  1180. public function deleteArtitle(Request $request) {
  1181. $validator = Validator::make($request->all(), [
  1182. 'NUMERO_ARTITULO' => 'required|string',
  1183. 'NUMERO_LINEA' => 'required|string',
  1184. 'USUARIO' => 'required|string',
  1185. ]);
  1186. if ($validator->fails()) {
  1187. return $this->responseController->makeResponse(
  1188. true,
  1189. "ERR_ARTITLE_DEL000: Se encontraron uno o más errores.",
  1190. $this->responseController->makeErrors($validator->errors()->messages()),
  1191. 401
  1192. );
  1193. }
  1194. DB::beginTransaction();
  1195. $requestData = $request->all();
  1196. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($requestData['USUARIO'], $requestData['NUMERO_LINEA']);
  1197. if ($arrResponseCheckUser['error']) {
  1198. DB::rollBack();
  1199. return $this->responseController->makeResponse(true, 'ERR_ARTITLE_DEL001:'.$arrResponseCheckUser['msg'], [], 401);
  1200. }
  1201. $usuario = $arrResponseCheckUser['response'];
  1202. try {
  1203. $artitleNumber = $this->encController->decrypt($requestData['NUMERO_ARTITULO']);
  1204. } catch (\Throwable $th) {
  1205. return $this->responseController->makeResponse(
  1206. true,
  1207. "ERR_ARTITLE_DEL002: Ocurrió un error al modificar el registro.",
  1208. $th->getMessage(),
  1209. 500
  1210. );
  1211. }
  1212. $now = $this->functionsController->now();
  1213. $currentDate = $now->toDateTimeString();
  1214. try {
  1215. $validateUpdate = DB::table('S002V01TARTI')
  1216. ->where('ARTI_IDAR', '=', $artitleNumber)
  1217. ->where('ARTI_NULI', '=', $requestData['NUMERO_LINEA'])
  1218. ->update([
  1219. 'ARTI_ESTA' => 'Eliminado',
  1220. 'ARTI_USMO' => $usuario,
  1221. 'ARTI_FEMO' => $currentDate,
  1222. 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1223. ]);
  1224. } catch (\Throwable $th) {
  1225. DB::rollBack();
  1226. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL003: Ocurrió un error al modificar el registro.", $th->getMessage(), 500);
  1227. }
  1228. if (!$validateUpdate) {
  1229. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL004: Ocurrió un error al modificar en la tabla.", [], 500);
  1230. }
  1231. try {
  1232. $arrDescription = DB::table('S002V01TDEAR')
  1233. ->where('DEAR_IDAR', '=', $artitleNumber)
  1234. ->get([ 'DEAR_IDDE AS NUMERO_DESCRIPCION' ]);
  1235. } catch (\Throwable $th) {
  1236. DB::rollBack();
  1237. 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);
  1238. }
  1239. foreach ($arrDescription as $keyDescription => $description) {
  1240. $numeroDescripcion = $description->NUMERO_DESCRIPCION;
  1241. try {
  1242. $validateUpdate = DB::table('S002V01TDEAR')
  1243. ->where('DEAR_IDDE', '=', $numeroDescripcion)
  1244. ->where('DEAR_NULI', '=', $requestData['NUMERO_LINEA'])
  1245. ->update([
  1246. 'DEAR_ESTA' => 'Eliminado',
  1247. 'DEAR_USMO' => $usuario,
  1248. 'DEAR_FEMO' => $currentDate,
  1249. 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1250. ]);
  1251. } catch (\Throwable $th) {
  1252. DB::rollBack();
  1253. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL007: Ocurrió un error al modificar el registro.", $th->getMessage(), 500);
  1254. }
  1255. if (!$validateUpdate) {
  1256. DB::rollBack();
  1257. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL006: Ocurrió un error al modificar en la tabla.", [], 500);
  1258. }
  1259. try {
  1260. $validateUpdate = DB::table('S002V01TINAR')
  1261. ->where('INAR_IDDE', '=', $numeroDescripcion)
  1262. ->where('INAR_NULI', '=', $requestData['NUMERO_LINEA'])
  1263. ->update([
  1264. 'INAR_ESTA' => 'Eliminado',
  1265. 'INAR_USMO' => $usuario,
  1266. 'INAR_FEMO' => $currentDate,
  1267. 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  1268. ]);
  1269. } catch (\Throwable $th) {
  1270. DB::rollBack();
  1271. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL009: Ocurrió un error al modificar el registro.", $th->getMessage(), 500);
  1272. }
  1273. if (!$validateUpdate) {
  1274. DB::rollBack();
  1275. return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL008: Ocurrió un error al modificar en la tabla.", [], 500);
  1276. }
  1277. }
  1278. DB::commit(); # Para guardar los cambios en la base de datos
  1279. return $this->responseController->makeResponse(false, "ÉXITO: Eliminación Exitosa");
  1280. }
  1281. public function generateArtitles(Request $request) {
  1282. $validator = Validator::make($request->all(), [
  1283. 'FILE_ZIP' => 'required',
  1284. 'NUMERO_LINEA' => 'required',
  1285. 'USUARIO' => 'required',
  1286. ]);
  1287. if ($validator->fails()) {
  1288. return $this->responseController->makeResponse(
  1289. true,
  1290. "ERR_ARTITLE_MOD000: Se encontraron uno o más errores.",
  1291. $this->responseController->makeErrors($validator->errors()->messages()),
  1292. 401
  1293. );
  1294. }
  1295. }
  1296. public function getArtitleByInformation($information, $user, $line) {
  1297. try {
  1298. $objInformation = (array) DB::table('S002V01TINAR')
  1299. ->where('INAR_IDIN', '=', $information)
  1300. ->where('INAR_ESTA', '=', 'Activo')
  1301. ->where('DEAR_ESTA', '=', 'Activo')
  1302. ->where('ARTI_ESTA', '=', 'Activo')
  1303. ->where('FAMI_ESTA', '=', 'Activo')
  1304. ->where('SUBF_ESTA', '=', 'Activo')
  1305. ->where('UNID_ESTA', '=', 'Activo')
  1306. ->where('PROV_ESTA', '=', 'Activo')
  1307. ->join('S002V01TDEAR', 'DEAR_IDDE', '=', 'INAR_IDDE')
  1308. ->join('S002V01TARTI', 'ARTI_IDAR', '=', 'DEAR_IDAR')
  1309. ->join('S002V01TFAMI', 'FAMI_COFA', '=', 'ARTI_COFA')
  1310. ->join('S002V01TSUBF', 'SUBF_COSU', '=', 'ARTI_COSU')
  1311. ->join('S002V01TUNID', 'UNID_IDUN', '=', 'DEAR_IDUN')
  1312. ->join('S002V01TPROV', 'PROV_NUPR', '=', 'DEAR_NUPR')
  1313. ->join('S002V01TCAMO', 'CAMO_COMO', '=', 'INAR_COMO')
  1314. ->first([
  1315. 'INAR_IDIN', // Identificador de Información del artículo
  1316. 'INAR_CODI', // Código del artículo
  1317. 'INAR_MODE', // Modelo del artículo
  1318. DB::raw('CONCAT("(", CAMO_COMO, ") ", CAMO_DESC) AS CAMO_COMO'),
  1319. 'INAR_PREC', // Precio
  1320. 'INAR_CARA', // Características
  1321. 'DEAR_IDDE', // Identificador de la descripción del artículo
  1322. 'DEAR_DESC', // Descripción del artículo
  1323. 'DEAR_CARA', // Características del artículo
  1324. 'DEAR_COWE', // Compra web
  1325. 'DEAR_IMAG', // Imagen
  1326. 'DEAR_IDUN', // Identificador de la unidad
  1327. 'UNID_NOMB', // Nombre de la unidad
  1328. 'UNID_ACRO', // Acrónimo de la familia
  1329. 'DEAR_NUPR', // Número del proveedor
  1330. 'ARTI_IDAR', // Identificador del artículo
  1331. 'ARTI_COFA', // Identificador de la familia
  1332. 'FAMI_NOFA', // Nombre de la familia
  1333. 'ARTI_COSU', // Identificador de la subfamilia
  1334. 'SUBF_NOSU', // Nombre de la subfamilia
  1335. 'ARTI_CODI', // Código del artículo
  1336. 'ARTI_NOMB', // Nombre del artículo
  1337. 'PROV_NOCO', // Nombre comercial
  1338. 'PROV_NOMB', // Nombre del proveedor
  1339. 'PROV_APPA', // Apellido paterno del proveedor
  1340. 'PROV_APMA', // Apellido materno del proveedor
  1341. 'PROV_CORR', // Correo electrónico
  1342. 'PROV_LAD1', // Lada 1
  1343. 'PROV_TEL1', // Teléfono 1
  1344. 'PROV_LAD2', // Lada 2
  1345. 'PROV_TEL2', // Teléfono 2
  1346. 'PROV_XRFC', // R.F.C
  1347. 'PROV_XTAX', // TAX ID
  1348. 'PROV_TIPO', // Tipo
  1349. 'PROV_SIWE', // Sitio Web
  1350. 'PROV_MEPA', // Metodos de pago
  1351. ]);
  1352. } catch (\Throwable $th) {
  1353. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYINFORMATION000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  1354. }
  1355. $objInformation['DEAR_IMAG'] = json_decode($objInformation['DEAR_IMAG']);
  1356. $arrUrlImage = array();
  1357. foreach ($objInformation['DEAR_IMAG'] as $key => $imagen) {
  1358. $responseDocument = $this->documentManagementController->privateGetPublicDocumentURL($imagen, $user, $line);
  1359. if ($responseDocument['error']) {
  1360. return $this->responseController->makeResponse(true, "ERR_ARTITLE_GETBYINFORMATION001: Ocurrió un error al obtener la URL de la imágen.", [], 500);
  1361. }
  1362. $arrUrlImage[] = $responseDocument['response']['public_uri'];
  1363. }
  1364. $objInformation['DEAR_IMAG'] = $arrUrlImage;
  1365. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $objInformation);
  1366. }
  1367. }