ArtitleController.php 68 KB

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