| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247 |
- <?php
- /*
- Desarrollador: Ing. Jean Jairo Benitez Meza
- Ultima Modificación: 05/09/2023
- Módulo: Gestión de Adquisiciones
- */
- namespace App\Http\Controllers;
- use App\Http\Controllers\Controller;
- use App\Http\Controllers\ResponseController;
- use App\Http\Controllers\EncryptionController;
- use App\Http\Controllers\FunctionsController;
- use App\Http\Controllers\DocumentManagementController;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Validator;
- use Illuminate\Support\Facades\Storage;
- use Illuminate\Http\File;
- use PhpOffice\PhpSpreadsheet\Spreadsheet;
- use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
- use Dompdf\Dompdf;
- class ProviderController extends Controller{
- private $responseController;
- private $encController;
- private $resourcesController;
- private $functionsController;
- private $documentManagementController;
-
- public function __construct() {
- $this->responseController = new ResponseController();
- $this->encController = new EncryptionController();
- $this->resourcesController = new ResourcesController();
- $this->functionsController = new FunctionsController();
- $this->documentManagementController = new DocumentManagementController();
- }
- public function getAllProvider($user, $line){
- try {
- $arrProvider = DB::table('S002V01TPROV')
- ->where('PROV_NULI', '=', $line)
- ->join('S002V01TREFI', 'REFI_CRFI', '=', 'PROV_CRFI')
- ->get([
- 'PROV_NUPR AS NUMERO_PROVEEDOR',
- 'PROV_NOCO AS RAZON_SOCIAL',
- 'PROV_NOMB AS NOMBRE',
- 'PROV_APPA AS PRIMER_APELLIDO',
- 'PROV_APMA AS SEGUNDO_APELLIDO',
- 'PROV_CORR AS CORREO',
- 'PROV_LAD1 AS LADA1',
- 'PROV_TEL1 AS TELEFONO1',
- 'PROV_LAD2 AS LADA2',
- 'PROV_TEL2 AS TELEFONO2',
- 'PROV_XRFC AS RFC',
- 'PROV_XTAX AS TAXID',
- 'PROV_CRFI AS REGIMEN_FISCAL',
- DB::raw('CONCAT(REFI_DRFI, " (", REFI_CRFI, ")") AS REGIMEN_FISCAL'),
- 'PROV_TIPO AS TIPO',
- 'PROV_TICO AS TIPO_CONTRIBUYENTE',
- 'PROV_SIWE AS SITIOWEB',
- 'PROV_MEPA AS METODO_PAGO',
- 'PROV_ESTA AS ESTADO',
- 'PROV_USRE AS USUARIO_REGISTRA',
- 'PROV_FERE AS FECHA_REGISTRA',
- 'PROV_USMO AS USUARIO_MODIFICA',
- 'PROV_FEMO AS FECHA_MODIFICA',
- 'PROV_CALL AS CALLE',
- 'PROV_NUEX AS EXTERIOR',
- 'PROV_NUIN AS INTERIOR',
- 'PROV_COPO AS CODIGO_POSTAL',
- 'PROV_COLO AS COLONIA',
- 'PROV_LOCA AS LOCALIDAD',
- 'PROV_MUNI AS MUNICIPIO',
- 'PROV_ENTI AS ENTIDAD',
- 'PROV_PAIS AS PAIS',
- ]);
- $arrResponse = array();
- foreach ($arrProvider as $provider) {
- $provider = (array) $provider;
- $provider['SEGUNDO_APELLIDO'] = $provider['SEGUNDO_APELLIDO'] == null ? '' : $provider['SEGUNDO_APELLIDO'];
- $arrReferences = DB::table('S002V01TPRRE')
- ->where('PRRE_NULI', '=', $line)
- ->where('PRRE_ESTA', '=', 'Activo')
- ->where('PRRE_NUPR', '=', $provider['NUMERO_PROVEEDOR'])
- ->get([
- 'PRRE_IDRE AS NUMERO_REFERENCIA',
- 'PRRE_EMPR AS RAZON_SOCIAL',
- 'PRRE_CORR AS CORREO',
- 'PRRE_LADA AS LADA',
- 'PRRE_TELE AS TELEFONO',
- 'PRRE_XRFC AS RFC',
- 'PRRE_DIRE AS DIRECCION',
- 'PRRE_ESTA AS ESTADO',
- 'PRRE_USRE AS USUARIO_REGISTRA',
- 'PRRE_FERE AS FECHA_REGISTRA',
- 'PRRE_USMO AS USUARIO_MODIFICA',
- 'PRRE_FEMO AS FECHA_MODIFICA',
- ]);
- $arrContacts = DB::table('S002V01TPRCO')
- ->where('PRCO_NULI', '=', $line)
- ->where('PRCO_ESTA', '=', 'Activo')
- ->where('PRCO_NUPR', '=', $provider['NUMERO_PROVEEDOR'])
- ->get([
- 'PRCO_IDCP AS NUMERO_CONTACTO',
- 'PRCO_NOMB AS NOMBRE_CONTACTO',
- 'PRCO_TIPO AS TIPO_CONTACTO',
- 'PRCO_CALL AS CALLE',
- 'PRCO_NUEX AS NUMERO_EXTERIOR',
- 'PRCO_NUIN AS NUMERO_INTERIOR',
- 'PRCO_COPO AS CODIGO_POSTAL',
- 'PRCO_COLO AS COLONIA',
- 'PRCO_LOCA AS LOCALIDAD',
- 'PRCO_MUNI AS MUNICIPIO',
- 'PRCO_ENTI AS ENTIDAD',
- 'PRCO_PAIS AS PAIS',
- 'PRCO_LAD1 AS LADA1',
- 'PRCO_TEL1 AS TELEFONO1',
- 'PRCO_LAD2 AS LADA2',
- 'PRCO_TEL2 AS TELEFONO2',
- 'PRCO_COR1 AS CORREO1',
- 'PRCO_COR2 AS CORREO2',
- 'PRCO_OBSE AS OBSERVACIONES',
- 'PRCO_ESTA AS ESTADO',
- 'PRCO_USRE AS USUARIO_REGISTRA',
- 'PRCO_FERE AS FECHA_REGISTRA',
- 'PRCO_USMO AS USUARIO_MODIFICA',
- 'PRCO_FEMO AS FECHA_MODIFICA',
- ]);
- $arrConditions = DB::table('S002V01TPRCN')
- ->where('PRCN_NULI', '=', $line)
- ->where('PRCN_ESTA', '=', 'Activo')
- ->where('PRCN_NUPR', '=', $provider['NUMERO_PROVEEDOR'])
- ->get([
- 'PRCN_IDCM AS NUMERO_CONDICION',
- 'PRCN_TIPO AS TIPO_CONDICION',
- 'PRCN_INFO AS INFORMACION',
- 'PRCN_ESTA AS ESTADO',
- 'PRCN_USRE AS USUARIO_REGISTRA',
- 'PRCN_FERE AS FECHA_REGISTRA',
- 'PRCN_USMO AS USUARIO_MODIFICA',
- 'PRCN_FEMO AS FECHA_MODIFICA',
- ]);
- $arrCatalogs = DB::table('S002V01TPRCE')
- ->where('PRCE_NULI', '=', $line)
- ->where('PRCE_ESTA', '=', 'Activo')
- ->where('PRCE_NUPR', '=', $provider['NUMERO_PROVEEDOR'])
- ->get([
- 'PRCE_IDCE AS NUMERO_CATALAGO',
- 'PRCE_CATA AS CATALAGO',
- 'PRCE_DESC AS DESCRIPCION',
- 'PRCE_XURL AS URL_CATALAGO',
- 'PRCE_ESTA AS ESTADO',
- 'PRCE_USRE AS USUARIO_REGISTRA',
- 'PRCE_FERE AS FECHA_REGISTRA',
- 'PRCE_USMO AS USUARIO_MODIFICA',
- 'PRCE_FEMO AS FECHA_MODIFICA',
- ]);
- $arrPayment = json_decode($provider['METODO_PAGO']);
- $arrPaymentFormat = array();
- foreach ($arrPayment as $key => $payment) {
- $arrPaymentFormat[] = [
- 'C_FORMAPAGO' => $key,
- 'DESCRIPCION' => $payment,
- ];
- }
- $provider['REFERENCIAS'] = $arrReferences;
- $provider['CONTACTOS'] = $arrContacts;
- $provider['CONDICIONES'] = $arrConditions;
- $provider['CATALAGOS'] = $arrCatalogs;
- $provider['METODOS_PAGO'] = $arrPaymentFormat;
- $arrResponse[] = $provider;
- }
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_GET000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrResponse);
- }
- public function getProvidersActives($user, $line) {
- try {
- $arrProvider = DB::table('S002V01TPROV')
- ->where('PROV_ESTA', '=', 'Activo')
- ->where('PROV_NULI', '=', $line)
- ->join('S002V01TREFI', 'REFI_CRFI', '=', 'PROV_CRFI')
- ->get([
- 'PROV_NUPR',
- 'PROV_NOCO',
- 'PROV_NOMB',
- 'PROV_APPA',
- 'PROV_APMA',
- 'PROV_CORR',
- 'PROV_LAD1',
- 'PROV_TEL1',
- 'PROV_LAD2',
- 'PROV_TEL2',
- 'PROV_XRFC',
- 'PROV_XTAX',
- 'REFI_CRFI',
- 'REFI_DRFI',
- 'PROV_TIPO',
- 'PROV_TICO',
- 'PROV_SIWE',
- 'PROV_MEPA',
- 'PROV_CALL',
- 'PROV_NUEX',
- 'PROV_NUIN',
- 'PROV_COPO',
- 'PROV_COLO',
- 'PROV_MUNI',
- 'PROV_LOCA',
- 'PROV_ENTI',
- 'PROV_PAIS',
- 'PROV_INEX',
- 'PROV_USRE',
- 'PROV_FERE',
- 'PROV_USMO',
- 'PROV_FEMO',
- 'PROV_FEAR',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_GETACTIVE000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrProvider);
- }
- public function getProvidersByNumber($provider, $user, $line) {
- try {
- $arrProvider = DB::table('S002V01TPROV')
- ->where('PROV_NUPR', '=', $provider)
- ->where('PROV_NULI', '=', $line)
- ->join('S002V01TREFI', 'REFI_CRFI', '=', 'PROV_CRFI')
- ->first([
- 'PROV_NUPR',
- 'PROV_NOCO',
- 'PROV_NOMB',
- 'PROV_APPA',
- 'PROV_APMA',
- 'PROV_CORR',
- 'PROV_LAD1',
- 'PROV_TEL1',
- 'PROV_LAD2',
- 'PROV_TEL2',
- 'PROV_XRFC',
- 'PROV_XTAX',
- 'REFI_CRFI',
- 'REFI_DRFI',
- 'PROV_TIPO',
- 'PROV_TICO',
- 'PROV_SIWE',
- 'PROV_MEPA',
- 'PROV_CALL',
- 'PROV_NUEX',
- 'PROV_NUIN',
- 'PROV_COPO',
- 'PROV_COLO',
- 'PROV_MUNI',
- 'PROV_LOCA',
- 'PROV_ENTI',
- 'PROV_PAIS',
- 'PROV_INEX',
- 'PROV_USRE',
- 'PROV_FERE',
- 'PROV_USMO',
- 'PROV_FEMO',
- 'PROV_FEAR',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_GETBYNUMBER000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrProvider);
- }
- public function updateProvider(Request $request) {
- $validator = Validator::make($request->all(), [
- 'line' => 'required|string',
- 'user' => 'required|string',
- 'obj_response' => 'required',
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_MOD000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- DB::beginTransaction();
- $requestData = $request->all();
- $line = $requestData['line'];
- try {
- $user = $this->encController->decrypt($request['user']);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD001: No se pudo obtener el usuario.", $th->getMessage(), 500);
- }
- $arrInformationPersonal = $requestData['obj_response']['INFORMACION'];
- $arrReferences = $requestData['obj_response']['REFERENCIAS'];
- $arrContacts = $requestData['obj_response']['CONTACTOS'];
- $arrConditions = $requestData['obj_response']['CONDICIONES'];
- $arrPaymentMedia = $requestData['obj_response']['METODOS_PAGO'];
- $arrCatalogs = $requestData['obj_response']['CATALAGOS'];
- $numeroProveedor = $arrInformationPersonal['NUMERO_PROVEEDOR'];
- $now = $this->functionsController->now();
- $currentDate = $now->toDateTimeString();
- $arrPaymentTemp = array();
- foreach ($arrPaymentMedia as $payment) {
- $arrPaymentTemp[$payment['C_FORMAPAGO']] = $payment['DESCRIPCION'];
- }
- try {
- $strPayment = json_encode($arrPaymentTemp);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD002: Ocurrió un error al obtener los datos del método de pago.", $th->getMessage(), 500);
- }
-
- try {
- $validateUpdateInformation = DB::table('S002V01TPROV')
- ->where('PROV_NUPR', '=', $numeroProveedor)
- ->where('PROV_NULI', '=', $line)
- ->update([
- 'PROV_NOCO' => $arrInformationPersonal['RAZON_SOCIAL'],
- 'PROV_NOMB' => $arrInformationPersonal['NOMBRE'],
- 'PROV_APPA' => $arrInformationPersonal['PRIMER_APELLIDO'],
- 'PROV_APMA' => $arrInformationPersonal['SEGUNDO_APELLIDO'] != '' ? $arrInformationPersonal['SEGUNDO_APELLIDO'] : null,
- 'PROV_CORR' => $arrInformationPersonal['CORREO'],
- 'PROV_LAD1' => $arrInformationPersonal['LADA1'],
- 'PROV_TEL1' => $arrInformationPersonal['TELEFONO1'],
- 'PROV_LAD2' => $arrInformationPersonal['LADA2'] != '' ? $arrInformationPersonal['LADA2'] : null,
- 'PROV_TEL2' => $arrInformationPersonal['TELEFONO2'] != '' ? $arrInformationPersonal['TELEFONO2'] : null,
- 'PROV_TICO' => $arrInformationPersonal['TIPO_CONTRIBUYENTE'],
- 'PROV_XRFC' => $arrInformationPersonal['RFC'],
- 'PROV_XTAX' => $arrInformationPersonal['TAXID'] != '' ? $arrInformationPersonal['TAXID'] : null,
- 'PROV_CRFI' => $arrInformationPersonal['REGIMEN_FISCAL'],
- 'PROV_TIPO' => $arrInformationPersonal['TIPO'],
- 'PROV_SIWE' => $arrInformationPersonal['SITIOWEB'],
- 'PROV_MEPA' => $strPayment,
- 'PROV_CALL' => $arrInformationPersonal['CALLE'],
- 'PROV_NUEX' => $arrInformationPersonal['EXTERIOR'],
- 'PROV_NUIN' => $arrInformationPersonal['INTERIOR'],
- 'PROV_COPO' => $arrInformationPersonal['CODIGO_POSTAL'],
- 'PROV_COLO' => $arrInformationPersonal['COLONIA'],
- 'PROV_LOCA' => $arrInformationPersonal['LOCALIDAD'] === 'Sin localidad' ? null : $arrInformationPersonal['LOCALIDAD'],
- 'PROV_MUNI' => $arrInformationPersonal['MUNICIPIO'],
- 'PROV_ENTI' => $arrInformationPersonal['ENTIDAD'],
- 'PROV_PAIS' => $arrInformationPersonal['PAIS'],
- 'PROV_USMO' => $user,
- 'PROV_FEMO' => $currentDate,
- 'PROV_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD003: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateUpdateInformation) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD004: Ocurrió un error al obtener el contenido.", [], 500);
- }
- foreach ($arrReferences as $references) {
- if ($references['ESTADO'] == 'Activo' || $references['ESTADO'] == 'Modificado') {
- try {
- $validateUpdateReference = DB::table('S002V01TPRRE')
- ->where('PRRE_IDRE', '=', $references['NUMERO_REFERENCIA'])
- ->where('PRRE_NUPR', '=', $numeroProveedor)
- ->where('PRRE_NULI', '=', $line)
- ->update([
- 'PRRE_EMPR' => $references['RAZON_SOCIAL'],
- 'PRRE_CORR' => $references['CORREO'],
- 'PRRE_LADA' => $references['LADA'],
- 'PRRE_TELE' => $references['TELEFONO'],
- 'PRRE_XRFC' => $references['RFC'],
- 'PRRE_DIRE' => $references['DIRECCION'],
- 'PRRE_USMO' => $user,
- 'PRRE_FEMO' => $currentDate,
- 'PRRE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD005: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateUpdateReference) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD006: Ocurrió un error al obtener el contenido. ", [], 500);
- }
- } else if ($references['ESTADO'] == 'Nuevo') {
- try {
- $validateInsertReference = DB::table('S002V01TPRRE')->insert([
- 'PRRE_NUPR' => $numeroProveedor,
- 'PRRE_EMPR' => $references['RAZON_SOCIAL'],
- 'PRRE_CORR' => $references['CORREO'],
- 'PRRE_LADA' => $references['LADA'],
- 'PRRE_TELE' => $references['TELEFONO'],
- 'PRRE_XRFC' => $references['RFC'],
- 'PRRE_DIRE' => $references['DIRECCION'],
- 'PRRE_NULI' => $line,
- 'PRRE_USRE' => $user,
- 'PRRE_FERE' => $currentDate,
- 'PRRE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD007: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateInsertReference) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD008: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } else if ($references['ESTADO'] == 'Eliminado'){
- try {
- $validateUpdateReference = DB::table('S002V01TPRRE')
- ->where('PRRE_IDRE', '=', $references['NUMERO_REFERENCIA'])
- ->where('PRRE_NUPR', '=', $numeroProveedor)
- ->where('PRRE_NULI', '=', $line)
- ->update([
- 'PRRE_ESTA' => 'Eliminado',
- 'PRRE_USMO' => $user,
- 'PRRE_FEMO' => $currentDate,
- 'PRRE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD009: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateUpdateReference) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD010: Ocurrió un error al obtener el contenido.", [], 500);
- }
- }
- }
- foreach ($arrContacts as $contacts) {
- if ($contacts['ESTADO'] == 'Activo' || $contacts['ESTADO'] == 'Modificado') {
- try {
- $validateUpdateContact = DB::table('S002V01TPRCO')
- ->where('PRCO_IDCP', '=', $contacts['NUMERO_CONTACTO'])
- ->where('PRCO_NUPR', '=', $numeroProveedor)
- ->where('PRCO_NULI', '=', $line)
- ->update([
- 'PRCO_NOMB' => $contacts['NOMBRE_CONTACTO'],
- 'PRCO_TIPO' => $contacts['TIPO_CONTACTO'],
- 'PRCO_CALL' => $contacts['CALLE'],
- 'PRCO_NUEX' => $contacts['NUMERO_EXTERIOR'],
- 'PRCO_NUIN' => $contacts['NUMERO_INTERIOR'] != '' ? $contacts['NUMERO_INTERIOR'] : null,
- 'PRCO_COPO' => $contacts['CODIGO_POSTAL'],
- 'PRCO_COLO' => $contacts['COLONIA'],
- 'PRCO_LOCA' => $contacts['LOCALIDAD'],
- 'PRCO_MUNI' => $contacts['MUNICIPIO'],
- 'PRCO_ENTI' => $contacts['ENTIDAD'],
- 'PRCO_PAIS' => $contacts['PAIS'],
- 'PRCO_TEL1' => $contacts['TELEFONO1'],
- 'PRCO_TEL2' => $contacts['TELEFONO2'] != '' ? $contacts['TELEFONO2'] : null,
- 'PRCO_COR1' => $contacts['CORREO1'],
- 'PRCO_COR2' => $contacts['CORREO2'] != '' ? $contacts['CORREO2'] : null,
- 'PRCO_OBSE' => $contacts['OBSERVACIONES'],
- 'PRCO_USMO' => $user,
- 'PRCO_FEMO' => $currentDate,
- 'PRCO_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD011: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateUpdateContact) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD012: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } else if ($contacts['ESTADO'] == 'Nuevo') {
- try {
- $validateInsertContact = DB::table('S002V01TPRCO')->insert([
- 'PRCO_NUPR' => $numeroProveedor,
- 'PRCO_NOMB' => $contacts['NOMBRE_CONTACTO'],
- 'PRCO_TIPO' => $contacts['TIPO_CONTACTO'],
- 'PRCO_CALL' => $contacts['CALLE'],
- 'PRCO_NUEX' => $contacts['NUMERO_EXTERIOR'],
- 'PRCO_NUIN' => $contacts['NUMERO_INTERIOR'] != '' ? $contacts['NUMERO_INTERIOR'] : null,
- 'PRCO_COPO' => $contacts['CODIGO_POSTAL'],
- 'PRCO_COLO' => $contacts['COLONIA'],
- 'PRCO_LOCA' => $contacts['LOCALIDAD'],
- 'PRCO_MUNI' => $contacts['MUNICIPIO'],
- 'PRCO_ENTI' => $contacts['ENTIDAD'],
- 'PRCO_PAIS' => $contacts['PAIS'],
- 'PRCO_LAD1' => $contacts['LADA1'],
- 'PRCO_TEL1' => $contacts['TELEFONO1'],
- 'PRCO_LAD2' => $contacts['LADA2'] != '' ? $contacts['LADA2'] : null,
- 'PRCO_TEL2' => $contacts['TELEFONO2'] != '' ? $contacts['TELEFONO2'] : null,
- 'PRCO_COR1' => $contacts['CORREO1'],
- 'PRCO_COR2' => $contacts['CORREO2'] != '' ? $contacts['CORREO2'] : null,
- 'PRCO_OBSE' => $contacts['OBSERVACIONES'],
- 'PRCO_NULI' => $line,
- 'PRCO_USRE' => $user,
- 'PRCO_FERE' => $currentDate,
- 'PRCO_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD013: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateInsertContact) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD014: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } else if ($contacts['ESTADO'] == 'Eliminado'){
- try {
- $validateUpdateContact = DB::table('S002V01TPRCO')
- ->where('PRCO_IDCP', '=', $contacts['NUMERO_CONTACTO'])
- ->where('PRCO_NUPR', '=', $numeroProveedor)
- ->where('PRCO_NULI', '=', $line)
- ->update([
- 'PRCO_ESTA' => 'Eliminado',
- 'PRCO_USMO' => $user,
- 'PRCO_FEMO' => $currentDate,
- 'PRCO_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD015: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateUpdateContact) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD016: Ocurrió un error al obtener el contenido.", [], 500);
- }
- }
- }
- foreach ($arrConditions as $conditions) {
- if ($conditions['ESTADO'] == 'Activo' || $conditions['ESTADO'] == 'Modificado') {
- try {
- $validateUpdateCondition = DB::table('S002V01TPRCN')
- ->where('PRCN_IDCM', '=', $conditions['NUMERO_CONDICION'])
- ->where('PRCN_NUPR', '=', $numeroProveedor)
- ->where('PRCN_NULI', '=', $line)
- ->update([
- 'PRCN_TIPO' => $conditions['TIPO_CONDICION'],
- 'PRCN_INFO' => $conditions['INFORMACION'],
- 'PRCN_USMO' => $user,
- 'PRCN_FEMO' => $currentDate,
- 'PRCN_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD017: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateUpdateCondition) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD018: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } else if ($conditions['ESTADO'] == 'Nuevo'){
- try {
- $validateInsertCondition = DB::table('S002V01TPRCN')->insert([
- 'PRCN_NUPR' => $numeroProveedor,
- 'PRCN_TIPO' => $conditions['TIPO_CONDICION'],
- 'PRCN_INFO' => $conditions['INFORMACION'],
- 'PRCN_NULI' => $line,
- 'PRCN_USRE' => $user,
- 'PRCN_FERE' => $currentDate,
- 'PRCN_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD019: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateInsertCondition) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD020: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } else if ($conditions['ESTADO'] == 'Eliminado'){
- try {
- $validateRegister = DB::table('S002V01TPRCN')
- ->where('PRCN_IDCM', '=', $conditions['NUMERO_CONDICION'])
- ->where('PRCN_NUPR', '=', $numeroProveedor)
- ->where('PRCN_NULI', '=', $line)
- ->exists();
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD021: Ocurrió un error al validar el registro.", $th->getMessage(), 500);
- }
- if ($validateRegister) {
- try {
- $validateUpdateConditions = DB::table('S002V01TPRCN')
- ->where('PRCN_IDCM', '=', $conditions['NUMERO_CONDICION'])
- ->where('PRCN_NUPR', '=', $numeroProveedor)
- ->where('PRCN_NULI', '=', $line)
- ->update([
- 'PRCN_ESTA' => 'Eliminado',
- 'PRCN_USMO' => $user,
- 'PRCN_FEMO' => $currentDate,
- 'PRCN_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
-
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD022: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateUpdateConditions) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD023: Ocurrió un error al obtener el contenido.", [], 500);
- }
- }
- }
- }
- foreach ($arrCatalogs as $catalogs) {
- if ($catalogs['ESTADO'] == 'Activo' || $catalogs['ESTADO'] == 'Modificado') {
- try {
- $validateUpdateCatalog = DB::table('S002V01TPRCE')
- ->where('PRCE_IDCE', '=', $catalogs['NUMERO_CATALAGO'])
- ->where('PRCE_NUPR', '=', $numeroProveedor)
- ->where('PRCE_NULI', '=', $line)
- ->update([
- 'PRCE_CATA' => $catalogs['CATALAGO'],
- 'PRCE_DESC' => $catalogs['DESCRIPCION'],
- 'PRCE_XURL' => $catalogs['URL_CATALAGO'],
- 'PRCE_USMO' => $user,
- 'PRCE_FEMO' => $currentDate,
- 'PRCE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD024: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateUpdateCatalog) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD025: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } else if ($catalogs['ESTADO'] == 'Nuevo'){
- try {
- $validateInsertCatalog = DB::table('S002V01TPRCE')->insert([
- 'PRCE_NUPR' => $numeroProveedor,
- 'PRCE_CATA' => $catalogs['CATALAGO'],
- 'PRCE_DESC' => $catalogs['DESCRIPCION'],
- 'PRCE_XURL' => $catalogs['URL_CATALAGO'],
- 'PRCE_NULI' => $line,
- 'PRCE_USRE' => $user,
- 'PRCE_FERE' => $currentDate,
- 'PRCE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD026: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateInsertCatalog) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD027: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } else if ($catalogs['ESTADO'] == 'Eliminado'){
- try {
- $validateExists = DB::table('S002V01TPRCE')
- ->where('PRCE_IDCE', '=', $catalogs['NUMERO_CATALAGO'])
- ->where('PRCE_NUPR', '=', $numeroProveedor)
- ->where('PRCE_NULI', '=', $line)
- ->exists();
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD028: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if ($validateExists) {
- try {
- $validateDelete = DB::table('S002V01TPRCE')
- ->where('PRCE_IDCE', '=', $catalogs['NUMERO_CATALAGO'])
- ->where('PRCE_NUPR', '=', $numeroProveedor)
- ->where('PRCE_NULI', '=', $line)
- ->update([
- 'PRCE_ESTA' => 'Eliminado',
- 'PRCE_USMO' => $user,
- 'PRCE_FEMO' => $currentDate,
- 'PRCE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
-
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD029: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if (!$validateDelete) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD030: Ocurrió un error al obtener el contenido.", [], 500);
- }
- }
- }
- }
- $response = [ 'idProvider' => $numeroProveedor ];
- try {
- $getSubcontract = (array) DB::table('S002V01TPESU')
- ->where('PESU_NUPR', '=', $numeroProveedor)
- ->where('PESU_NULI', '=', $line)
- ->first();
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD031: Ocurrió un error al válidar si existe en subcontratista.", $th->getMessage(), 500);
- }
-
- if ( !empty($getSubcontract)) {
- try {
- $updateSubcontract = DB::table('S002V01TPESU')
- ->where('PESU_NUPR', '=', $numeroProveedor)
- ->where('PESU_NULI', '=', $line)
- ->update([
- 'PESU_RASO' => $arrInformationPersonal['RAZON_SOCIAL'],
- 'PESU_REFI' => $arrInformationPersonal['REGIMEN_FISCAL'],
- 'PESU_XRFC' => $arrInformationPersonal['RFC'] != '' ? $arrInformationPersonal['RFC'] : null,
- 'PESU_TIPO' => $arrInformationPersonal['TIPO_CONTRIBUYENTE'],
- 'PESU_CORR' => $arrInformationPersonal['CORREO'],
- 'PESU_EXTR' => $arrInformationPersonal['TIPO'] === 'Nacional' ? 'No' : 'Si',
- 'PESU_TAID' => $arrInformationPersonal['TAXID'] != '' ? $arrInformationPersonal['TAXID'] : null,
- 'PESU_CALL' => $arrInformationPersonal['CALLE'],
- 'PESU_NUEX' => $arrInformationPersonal['EXTERIOR'],
- 'PESU_NUIN' => $arrInformationPersonal['INTERIOR'],
- 'PESU_COLO' => $arrInformationPersonal['COLONIA'],
- 'PESU_CIUD' => $arrInformationPersonal['MUNICIPIO'],
- 'PESU_LOCA' => $arrInformationPersonal['LOCALIDAD'] === 'Sin localidad' ? null : $arrInformationPersonal['LOCALIDAD'],
- 'PESU_COPO' => $arrInformationPersonal['CODIGO_POSTAL'],
- 'PESU_ENFE' => $arrInformationPersonal['ENTIDAD'],
- 'PESU_IDPA' => $arrInformationPersonal['PAIS'],
- 'PESU_TEL1' => $arrInformationPersonal['TELEFONO1'],
- 'PESU_LAT1' => $arrInformationPersonal['LADA1'],
- 'PESU_TEL2' => $arrInformationPersonal['TELEFONO2'] != '' ? $arrInformationPersonal['TELEFONO2'] : null,
- 'PESU_LAT2' => $arrInformationPersonal['LADA2'] != '' ? $arrInformationPersonal['LADA2'] : null,
- 'PESU_USMO' => $user,
- 'PESU_FEMO' => $currentDate,
- ]
- );
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD032: Ocurrió un error al modificar el subcontratista.", $th->getMessage(), 500);
- }
- if ( !$updateSubcontract ) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD033: No se pudo modificar el subcontratista.", [], 500);
- }
- $response['subcontract'] = $getSubcontract;
- }
-
-
- DB::commit();
- return $this->responseController->makeResponse(false, "EXITO: Modificación Exitosa", $response);
- }
- public function registerProvider(Request $request) {
- $validator = Validator::make($request->all(), [
- 'line' => 'required|string',
- 'user' => 'required|string',
- 'obj_response' => 'required',
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_REG000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- DB::beginTransaction();
- $requestData = $request->all();
- $line = $requestData['line'];
- try {
- $user = $this->encController->decrypt($requestData['user']);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG001: Ocurrió un error al obtener el usuario.", $th->getMessage(), 500);
- }
- $arrInformationPersonal = (array) $requestData['obj_response']['INFORMACION'];
- $arrReferences = (array) $requestData['obj_response']['REFERENCIAS'];
- $arrContacts = (array) $requestData['obj_response']['CONTACTOS'];
- $arrConditions = (array) $requestData['obj_response']['CONDICIONES'];
- $arrPaymentMedia = (array) $requestData['obj_response']['METODOS_PAGO'];
- $arrCatalogs = (array) $requestData['obj_response']['CATALAGOS'];
- $now = $this->functionsController->now();
- $currentDate = $now->toDateTimeString();
- $arrPaymentTemp = array();
- foreach ($arrPaymentMedia as $payment) {
- $arrPaymentTemp[$payment['MEPA_IDME']] = $payment['MEPA_NOMB'];
- }
- try {
- $strPayment = json_encode($arrPaymentTemp);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG002: Ocurrió un error al obtener los métodos de pago del proveedor.", $th->getMessage(), 500);
- }
- $idSubcontract = null;
- if (!is_null($arrInformationPersonal['ID_SUBCONTRACT'])) {
- $idSubcontract = $arrInformationPersonal['ID_SUBCONTRACT'];
- try {
- $validateSubcontract = DB::table('S002V01TPESU')
- ->where('PESU_IDPS', '=', $idSubcontract)
- ->where('PESU_NULI', '=', $line)
- ->exists();
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG003: Ocurrió un error al validar que el subcontratista exista.", $th->getMessage(), 500);
- }
- if (!$validateSubcontract) {
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG004: El subcontratista no existe.", [], 500);
- }
- }
-
- try {
- $idProdiver = DB::table('S002V01TPROV')->insertGetId([
- 'PROV_NOCO' => $arrInformationPersonal['RAZON_SOCIAL'],
- 'PROV_IDPS' => $idSubcontract,
- 'PROV_NOMB' => $arrInformationPersonal['NOMBRE'],
- 'PROV_APPA' => $arrInformationPersonal['PRIMER_APELLIDO'],
- 'PROV_APMA' => $arrInformationPersonal['SEGUNDO_APELLIDO'] != '' ? $arrInformationPersonal['SEGUNDO_APELLIDO'] : null,
- 'PROV_CORR' => $arrInformationPersonal['CORREO'],
- 'PROV_LAD1' => $arrInformationPersonal['LADA1'],
- 'PROV_TEL1' => $arrInformationPersonal['TELEFONO1'],
- 'PROV_LAD2' => $arrInformationPersonal['LADA2'],
- 'PROV_TEL2' => $arrInformationPersonal['TELEFONO2'] != '' ? $arrInformationPersonal['TELEFONO2'] : null,
- 'PROV_TICO' => $arrInformationPersonal['TIPO_CONTRIBUYENTE'],
- 'PROV_XRFC' => $arrInformationPersonal['RFC'],
- 'PROV_XTAX' => $arrInformationPersonal['TAXID'] != '' ? $arrInformationPersonal['TAXID'] : null,
- 'PROV_CRFI' => $arrInformationPersonal['REGIMEN_FISCAL'],
- 'PROV_TIPO' => $arrInformationPersonal['TIPO'],
- 'PROV_SIWE' => $arrInformationPersonal['SITIOWEB'],
- 'PROV_CALL' => $arrInformationPersonal['CALLE'],
- 'PROV_NUEX' => $arrInformationPersonal['EXTERIOR'],
- 'PROV_NUIN' => $arrInformationPersonal['INTERIOR'] != '' ? $arrInformationPersonal['INTERIOR'] : null,
- 'PROV_COPO' => $arrInformationPersonal['CODIGO_POSTAL'],
- 'PROV_COLO' => $arrInformationPersonal['COLONIA'],
- 'PROV_LOCA' => $arrInformationPersonal['LOCALIDAD'] === 'Sin localidad' ? null : $arrInformationPersonal['LOCALIDAD'],
- 'PROV_MUNI' => $arrInformationPersonal['MUNICIPIO'],
- 'PROV_ENTI' => $arrInformationPersonal['ENTIDAD'],
- 'PROV_PAIS' => $arrInformationPersonal['PAIS'],
- 'PROV_MEPA' => $strPayment,
- 'PROV_NULI' => $line,
- 'PROV_USRE' => $user,
- 'PROV_FERE' => $currentDate,
- 'PROV_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG005: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- if ( !is_null($idSubcontract )) {
- try {
- $validateUpdateSubcontract = DB::table('S002V01TPESU')
- ->where('PESU_IDPS', '=', $idSubcontract)
- ->where('PESU_NULI', '=', $line)
- ->update([
- 'PESU_NUPR' => $idProdiver,
- 'PESU_USMO' => $user,
- 'PESU_FEMO' => $currentDate,
- 'PESU_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG006: Ocurrió un error enlazar el proveedor con el subcontratista.", $th->getMessage(), 500);
- }
- if (!$validateUpdateSubcontract) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG007: No se pudo enlazar el proveedor con el subcontratista.", [], 500);
- }
- }
- foreach ($arrReferences as $references) {
- if ($references['ESTADO'] == 'Activo' || $references['ESTADO'] == 'Nuevo') {
- $insertReferences = [
- 'PRRE_NUPR' => $idProdiver,
- 'PRRE_EMPR' => $references['RAZON_SOCIAL'],
- 'PRRE_CORR' => $references['CORREO'],
- 'PRRE_LADA' => $references['LADA'],
- 'PRRE_TELE' => $references['TELEFONO'],
- 'PRRE_XRFC' => $references['RFC'],
- 'PRRE_DIRE' => $references['DIRECCION'],
- 'PRRE_NULI' => $line,
- 'PRRE_USRE' => $user,
- 'PRRE_FERE' => $currentDate,
- 'PRRE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $resp = DB::table('S002V01TPRRE')->insert($insertReferences);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG008: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG009: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- }
- }
- foreach ($arrContacts as $contacts) {
- if ($contacts['ESTADO'] == 'Activo' || $contacts['ESTADO'] == 'Nuevo') {
- $insertContacts = [
- 'PRCO_NUPR' => $idProdiver,
- 'PRCO_NOMB' => $contacts['NOMBRE_CONTACTO'],
- 'PRCO_TIPO' => $contacts['TIPO_CONTACTO'],
- 'PRCO_CALL' => $contacts['CALLE'],
- 'PRCO_NUEX' => $contacts['NUMERO_EXTERIOR'],
- 'PRCO_NUIN' => $contacts['NUMERO_INTERIOR'] != '' ? $contacts['NUMERO_INTERIOR'] : null,
- 'PRCO_COPO' => $contacts['CODIGO_POSTAL'],
- 'PRCO_LOCA' => $contacts['LOCALIDAD'],
- 'PRCO_COLO' => $contacts['COLONIA'],
- 'PRCO_MUNI' => $contacts['MUNICIPIO'],
- 'PRCO_ENTI' => $contacts['ENTIDAD'],
- 'PRCO_PAIS' => $contacts['PAIS'],
- 'PRCO_LAD1' => $contacts['LADA1'],
- 'PRCO_TEL1' => $contacts['TELEFONO1'],
- 'PRCO_LAD2' => $contacts['LADA2'] != '' ? $contacts['LADA2'] : null,
- 'PRCO_TEL2' => $contacts['TELEFONO2'] != '' ? $contacts['TELEFONO2'] : null,
- 'PRCO_COR1' => $contacts['CORREO1'],
- 'PRCO_COR2' => $contacts['CORREO2'] != '' ? $contacts['CORREO2'] : null,
- 'PRCO_OBSE' => $contacts['OBSERVACIONES'],
- 'PRCO_NULI' => $line,
- 'PRCO_USRE' => $user,
- 'PRCO_FERE' => $currentDate,
- 'PRCO_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $resp = DB::table('S002V01TPRCO')->insert($insertContacts);
-
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG010: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG011: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- }
- }
- foreach ($arrConditions as $conditions) {
- if ($conditions['ESTADO'] == 'Activo') {
- $insertConditions = [
- 'PRCN_NUPR' => $idProdiver,
- 'PRCN_TIPO' => $conditions['TIPO_CONDICION'],
- 'PRCN_INFO' => $conditions['INFORMACION'],
- 'PRCN_NULI' => $line,
- 'PRCN_USRE' => $user,
- 'PRCN_FERE' => $currentDate,
- 'PRCN_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $resp = DB::table('S002V01TPRCN')->insert($insertConditions);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG012: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG013: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- }
- }
- foreach ($arrCatalogs as $catalogs) {
- if ($catalogs['ESTADO'] == 'Activo' || $catalogs['ESTADO'] == 'Nuevo') {
- $insertCatalogs = [
- 'PRCE_NUPR' => $idProdiver,
- 'PRCE_CATA' => $catalogs['CATALAGO'],
- 'PRCE_DESC' => $catalogs['DESCRIPCION'],
- 'PRCE_XURL' => $catalogs['URL_CATALAGO'],
- 'PRCE_NULI' => $line,
- 'PRCE_USRE' => $user,
- 'PRCE_FERE' => $currentDate,
- 'PRCE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $resp = DB::table('S002V01TPRCE')->insert($insertCatalogs);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG014: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_REG015: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- }
- }
- $response = [ 'idProvider' => $idProdiver ];
- DB::commit();
- return $this->responseController->makeResponse(false, "EXITO: Registro Exitoso", $response);
- }
- public function deleteProvider(Request $request) {
- $validator = Validator::make($request->all(), [
- 'line' => 'required|string',
- 'user' => 'required|string',
- 'numero_proveedor' => 'required|string'
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_DEL000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- DB::beginTransaction();
- $requestData = $request->all();
-
- $now = $this->functionsController->now();
- $currentDate = $now->toDateTimeString();
- $line = $requestData['line'];
- try {
- $numeroProveedor = $this->encController->decrypt($requestData['numero_proveedor']);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_DEL001: Ocurrió un error al obtener el número del proveedor.", $th->getMessage(), 500);
- }
- try {
- $user = $this->encController->decrypt($requestData['user']);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_DEL002: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- $update = [
- 'PROV_ESTA' => 'Eliminado',
- 'PROV_USMO' => $user,
- 'PROV_FEMO' => $currentDate,
- 'PROV_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $resp = DB::table('S002V01TPROV')->where('PROV_NUPR', '=', $numeroProveedor)->where('PROV_NULI', '=', $line)->update($update);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_DEL003: Ocurrió un error al obtener el contenido. ", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_DEL004: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- try {
- $resp = DB::table('S002V01TPRRE')
- ->where('PRRE_NUPR', '=', $numeroProveedor)
- ->where('PRRE_NULI', '=', $line)
- ->update([
- 'PRRE_ESTA' => 'Eliminado',
- 'PRRE_USMO' => $user,
- 'PRRE_FEMO' => $currentDate,
- 'PRRE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_DEL006: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- try {
- $resp = DB::table('S002V01TPRCO')
- ->where('PRCO_NUPR', '=', $numeroProveedor)
- ->where('PRCO_NULI', '=', $line)
- ->update([
- 'PRCO_ESTA' => 'Eliminado',
- 'PRCO_USMO' => $user,
- 'PRCO_FEMO' => $currentDate,
- 'PRCO_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_DEL008: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- try {
- $resp = DB::table('S002V01TPRCN')
- ->where('PRCN_NUPR', '=', $numeroProveedor)
- ->where('PRCN_NULI', '=', $line)
- ->update([
- 'PRCN_ESTA' => 'Eliminado',
- 'PRCN_USMO' => $user,
- 'PRCN_FEMO' => $currentDate,
- 'PRCN_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_DEL010: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- try {
- $resp = DB::table('S002V01TPRCE')
- ->where('PRCE_NUPR', '=', $numeroProveedor)
- ->where('PRCE_NULI', '=', $line)
- ->update([
- 'PRCE_ESTA' => 'Eliminado',
- 'PRCE_USMO' => $user,
- 'PRCE_FEMO' => $currentDate,
- 'PRCE_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_DEL012: Ocurrió un error al obtener el contenido.", $th->getMessage(), 500);
- }
- DB::commit();
- return $this->responseController->makeResponse(false, "EXITO: Eliminación correcta",);
- }
- public function getProviderByArtitle(Request $request) {
- $validator = Validator::make($request->all(), [
- 'NUMERO_ARTICULO' => 'required|string',
- 'NUMERO_LINEA' => 'required|string',
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_GETBYARTITLE000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- $response = $request->all();
- $numeroArticulo = $this->encController->decrypt($response['NUMERO_ARTICULO']);
- try {
- $arrDescription = DB::table('S002V01TDEAR')
- ->where('DEAR_ESTA', '=', 'Activo')
- ->where('DEAR_IDAR', '=', $numeroArticulo)
- ->join('S002V01TPROV', 'DEAR_NUPR', '=', 'PROV_NUPR')
- ->get([
- 'DEAR_IDDE AS NUMERO_DESCRIPTION',
- 'PROV_NUPR AS NUMERO_PROVEEDOR',
- 'PROV_NOCO AS RAZON_SOCIAL',
- 'PROV_NOMB AS NOMBRE',
- 'PROV_APPA AS PRIMER_APELLIDO',
- 'PROV_APMA AS SEGUNDO_APELLIDO',
- 'PROV_CORR AS CORREO',
- 'PROV_LAD1 AS LADA1',
- 'PROV_TEL1 AS TELEFONO1',
- 'PROV_LAD2 AS LADA2',
- 'PROV_TEL2 AS TELEFONO2',
- 'PROV_TICO AS TIPO_CONTRIBUYENTE',
- 'PROV_XRFC AS RFC',
- 'PROV_XTAX AS TAXID',
- 'PROV_CRFI AS REGIMEN_FISCAL',
- 'PROV_TIPO AS TIPO',
- 'PROV_SIWE AS SITIOWEB',
- 'PROV_MEPA AS METODO_PAGO',
- 'PROV_ESTA AS ESTADO',
- 'PROV_USRE AS USUARIO_REGISTRA',
- 'PROV_FERE AS FECHA_REGISTRA',
- 'PROV_USMO AS USUARIO_MODIFICA',
- 'PROV_FEMO AS FECHA_MODIFICA',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_PROVIDER_GETBYARTITLE001: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO", $arrDescription);
- }
- public function getArtitlesByProvider($encProvider, $user, $line) {
- DB::beginTransaction();
- // Se obtiene el número del proveedor
- try {
- $provider = $this->encController->decrypt($encProvider);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLES_PROVIDER_GET000: Ocurrió un error al obtener el número del proveedor.",
- $th->getMessage(),
- 500
- );
- }
-
- // Verifica su existe el proveedor
- try {
- $validateExist = DB::table('S002V01TPROV')
- ->where('PROV_NUPR', '=', $provider)
- ->where('PROV_NULI', '=', $line)
- ->exists();
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLES_PROVIDER_GET001: Ocurrió un error al identificar el proveedor.",
- $th->getMessage(),
- 500
- );
- }
- // Valida si existe el proveedor
- if (!$validateExist) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLES_PROVIDER_GET002: El proveedor no existe",
- [],
- 500
- );
- }
- // Obtiene todos las descripciones de los artículos del proveedor
- try {
- $getDescriptionArtitles = DB::table('S002V01TDEAR')
- ->where('DEAR_NUPR', '=', $provider)
- ->where('DEAR_NULI', '=', $line)
- ->where('DEAR_ESTA', '=', 'Activo')
- ->get([
- 'DEAR_IDDE', # Identificador de la descripción
- 'DEAR_IMAG', # Imagenes de los artículos
- 'DEAR_DESC', # Descripción del artículo
- 'DEAR_CARA', # Características del artículo
- 'DEAR_COWE', # Compra web
- 'DEAR_IDUN', # Identificador del tipo de unidad
- 'DEAR_IDAR', # Identificador del artículo principal
- 'DEAR_USRE', # Usuario de registro
- 'DEAR_FERE', # Fecha de registro
- 'DEAR_USMO', # Usuario de modificación
- 'DEAR_FEMO', # Fecha de modificación
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLES_PROVIDER_GET003: El proveedor no existe", $th->getMessage(), 500);
- }
- // El resultado pasa a ser un arreglo
- $arrDescriptionArtitles = json_decode(json_encode($getDescriptionArtitles), true);
- $arrDescription = array();
- foreach ($arrDescriptionArtitles as $keyDescription => $descriptionArtitle) {
- // Obtiene las imagenes y las pasa a un arreglo
- $arrImages = json_decode($descriptionArtitle['DEAR_IMAG']);
- $arrUrlImage = array();
- foreach ($arrImages as $keyImages => $images) {
- $responseDocument = $this->documentManagementController->getPublicDocumentURL($images, $user, $line);
- $arrResponseDocument = json_decode($responseDocument->original, true);
- if ($arrResponseDocument['error']) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLES_PROVIDER_GET004: Ocurrió un error al obtener la URL de la imágen.", [], 500);
- }
- $arrUrlImage[] = $arrResponseDocument['response']['public_uri'];
- }
- $descriptionArtitle['DEAR_IMAG'] = $arrUrlImage;
- // Obtiene la información principal del artículo
- try {
- $objArtitle = DB::table('S002V01TARTI')
- ->where('ARTI_IDAR', '=', $descriptionArtitle['DEAR_IDAR'])
- ->where('ARTI_NULI', '=', $line)
- ->where('ARTI_ESTA', '=', 'Activo')
- ->join('S002V01TFAMI', 'ARTI_COFA', '=', 'FAMI_COFA')
- ->join('S002V01TSUBF', 'ARTI_COSU', '=', 'SUBF_COSU')
- ->first([
- 'ARTI_IDAR', # Identificador del artículo
- 'ARTI_COFA', # Identificador de la familia del artículo
- 'FAMI_NOFA', # Nombre de la familia del artículo
- 'ARTI_COSU', # Identificador de la subfamilia del artículo
- 'SUBF_NOSU', # Nombre de la subfamilia del artículo
- 'ARTI_CODI', # Código de barras del artículo
- 'ARTI_NOMB', # Nombre principal del artículo
- // 'ARTI_USRE', # Usuario de registro
- // 'ARTI_FERE', # Fecha de registro
- // 'ARTI_USMO', # Usuario de modificación
- // 'ARTI_FEMO', # Fecha de modificación
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLES_PROVIDER_GET005: Ocurrió un error al obtener la información del artículo.", $th->getMessage(), 500);
- }
- // La información es guardada en el arreglo de respuesta
- foreach ($objArtitle as $keyArtitle => $artitle) {
- $descriptionArtitle[$keyArtitle] = $artitle;
- }
- // Se obtiene la unidad del artículo
- try {
- $objUnit = DB::table('S002V01TUNID')
- ->where('UNID_IDUN', '=', $descriptionArtitle['DEAR_IDUN'])
- ->where('UNID_NULI', '=', $line)
- ->where('UNID_ESTA', '=', 'Activo')
- ->first([
- 'UNID_IDUN', # Identificador de la unidad
- 'UNID_NOMB', # Nombre de la unidad
- 'UNID_ACRO', # Acrónimo de la unidad
- 'UNID_USRE', # Usuario de registro
- 'UNID_FERE', # Fecha de registro
- 'UNID_USMO', # Usuario de modificación
- 'UNID_FEMO', # Fecha de modificación
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLES_PROVIDER_GET006: Ocurrió un error al obtener el tipo de unidad.",
- $th->getMessage(),
- 500
- );
- }
- // La información es guardada en el arreglo de respuesta
- $descriptionArtitle['DEAR_IDUN'] = $objUnit;
-
- // Se obtienen los detalles de la descripción
- try {
- $getDetailsDescription = DB::table('S002V01TINAR')
- ->where('INAR_IDDE', '=', $descriptionArtitle['DEAR_IDDE'])
- ->where('INAR_NULI', '=', $line)
- ->where('INAR_ESTA', '=', 'Activo')
- ->get([
- 'INAR_IDIN', # Identificador de los detalles
- 'INAR_CODI', # Código del artículo
- 'INAR_MODE', # Módelo del artículo
- 'INAR_COMO', # Tipo de moneda
- 'INAR_PREC', # Precio unitario del artículo
- 'INAR_MOMI', # Mónto mínimo
- 'INAR_CARA', # Características
- 'INAR_USRE', # Usuario de registro
- 'INAR_FERE', # Fecha de registro
- 'INAR_USMO', # Usuario de modificación
- 'INAR_FEMO', # Fecha de modificación
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLES_PROVIDER_GET007: Ocurrió un error al obtener los detalles de la descripción del artículo.",
- $th->getMessage(),
- 500
- );
- }
-
- // La información es guardada en el arreglo de respuesta
- $descriptionArtitle['DETAILS'] = $getDetailsDescription;
- // Se almacen el arreglo de respuesta en el arreglo principal
- $arrDescription[] = $descriptionArtitle;
- }
- DB::commit(); # Para guardar los cambios en la base de datos
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta exitosa", $arrDescription);
- }
- public function downloadArtitlesByProvider(Request $request) {
- $validator = Validator::make($request->all(), [
- 'PROVIDER' => 'required|string',
- 'USER' => 'required|string',
- 'LINE_NUMBER' => 'required|string',
- 'DOWNLOAD' => 'required|array',
- ]);
-
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_DOWNLOAD_ARTITLE_DOW000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
-
- $responseData = $request->all();
- try {
- $user = $this->encController->decrypt($responseData['USER']);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_DOWNLOAD_ARTITLE_DOW001: No se pudo obtener los datos del usuario", $th->getMessage(), 500);
- }
-
- // Verifica su existe el proveedor
- try {
- $validateExist = DB::table('S002V01TPROV')
- ->where('PROV_NUPR', '=', $responseData['PROVIDER'])
- ->where('PROV_NULI', '=', $responseData['LINE_NUMBER'])
- ->exists();
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_DOWNLOAD_ARTITLE_DOW002: Ocurrió un error al identificar el proveedor.",
- $th->getMessage(),
- 500
- );
- }
- // Valida si existe el proveedor
- if (!$validateExist) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_DOWNLOAD_ARTITLE_DOW003: El proveedor no existe", [], 500);
- }
- $arrDescriptionId = $responseData['DOWNLOAD'];
- $arrDataArtitles = array();
- foreach ($arrDescriptionId as $keyId => $idDescription) {
- // Obtiene todos las descripciones de los artículos del proveedor
- try {
- $getDescriptionArtitles = DB::table('S002V01TDEAR')
- ->where('DEAR_IDDE', '=', $idDescription)
- ->where('DEAR_NUPR', '=', $responseData['PROVIDER'])
- ->where('DEAR_NULI', '=', $responseData['LINE_NUMBER'])
- ->where('DEAR_ESTA', '=', 'Activo')
- ->first([
- 'DEAR_IDDE', # Identificador de la descripción
- 'DEAR_IMAG', # Imagenes de los artículos
- 'DEAR_DESC', # Descripción del artículo
- 'DEAR_CARA', # Características del artículo
- 'DEAR_COWE', # Compra web
- 'DEAR_IDUN', # Identificador del tipo de unidad
- 'DEAR_IDAR', # Identificador del artículo principal
- 'DEAR_USRE', # Usuario de registro
- 'DEAR_FERE', # Fecha de registro
- 'DEAR_USMO', # Usuario de modificación
- 'DEAR_FEMO', # Fecha de modificación
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_DOWNLOAD_ARTITLE_DOW004: El proveedor no existe", $th->getMessage(), 500);
- }
- $arrDescriptionArtitles = (array) $getDescriptionArtitles;
- // Obtiene la información principal del artículo
- try {
- $objArtitle = DB::table('S002V01TARTI')
- ->where('ARTI_IDAR', '=', $arrDescriptionArtitles['DEAR_IDAR'])
- ->where('ARTI_NULI', '=', $responseData['LINE_NUMBER'])
- ->where('ARTI_ESTA', '=', 'Activo')
- ->join('S002V01TFAMI', 'ARTI_COFA', '=', 'FAMI_COFA')
- ->join('S002V01TSUBF', 'ARTI_COSU', '=', 'SUBF_COSU')
- ->first([
- 'ARTI_IDAR', # Identificador del artículo
- 'ARTI_COFA', # Identificador de la familia del artículo
- 'FAMI_NOFA', # Nombre de la familia del artículo
- 'ARTI_COSU', # Identificador de la subfamilia del artículo
- 'SUBF_NOSU', # Nombre de la subfamilia del artículo
- 'ARTI_CODI', # Código de barras del artículo
- 'ARTI_NOMB', # Nombre principal del artículo
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_DOWNLOAD_ARTITLE_DOW005: Ocurrió un error al obtener la información del artículo.",
- $th->getMessage(),
- 500
- );
- }
- $objArtitle = (array) $objArtitle;
- // La información es guardada en el arreglo de respuesta
- foreach ($objArtitle as $keyArtitle => $artitle) {
- $arrDescriptionArtitles[$keyArtitle] = $artitle;
- }
- // Se obtiene la unidad del artículo
- try {
- $objUnit = DB::table('S002V01TUNID')
- ->where('UNID_IDUN', '=', $arrDescriptionArtitles['DEAR_IDUN'])
- ->where('UNID_NULI', '=', $responseData['LINE_NUMBER'])
- ->where('UNID_ESTA', '=', 'Activo')
- ->first([
- 'UNID_IDUN', # Identificador de la unidad
- 'UNID_NOMB', # Nombre de la unidad
- 'UNID_ACRO', # Acrónimo de la unidad
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_DOWNLOAD_ARTITLE_DOW006: Ocurrió un error al obtener el tipo de unidad.",
- $th->getMessage(),
- 500
- );
- }
- // La información es guardada en el arreglo de respuesta
- $arrDescriptionArtitles['DEAR_IDUN'] = $objUnit;
- // Se obtienen los detalles de la descripción
- try {
- $getDetailsDescription = DB::table('S002V01TINAR')
- ->where('INAR_IDDE', '=', $idDescription)
- ->where('INAR_NULI', '=', $responseData['LINE_NUMBER'])
- ->where('INAR_ESTA', '=', 'Activo')
- ->get([
- 'INAR_IDIN', # Identificador de los detalles
- 'INAR_CODI', # Código del artículo
- 'INAR_MODE', # Módelo del artículo
- 'INAR_MONE', # Tipo de moneda
- 'INAR_PREC', # Precio unitario del artículo
- 'INAR_MOMI', # Mónto mínimo
- 'INAR_CARA', # Características
- 'INAR_USRE', # Usuario de registro
- 'INAR_FERE', # Fecha de registro
- 'INAR_USMO', # Usuario de modificación
- 'INAR_FEMO', # Fecha de modificación
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_DOWNLOAD_ARTITLE_DOW007: Ocurrió un error al obtener los detalles de la descripción del artículo.",
- $th->getMessage(),
- 500
- );
- }
- $arrDetailsDescription = json_decode(json_encode($getDetailsDescription), true);
- $arrDescriptionArtitles['DETAILS'] = $arrDetailsDescription;
- $arrDataArtitles[] = $arrDescriptionArtitles;
- }
- // Se inicializa el nombre del documento
- $nameDocument = "CONTENT_ARTITLE_BY_".$responseData['PROVIDER'].".xlsx";
- // Se crea el documento y se obtiene el base64 del documento
- $base64Document = $this->createDocument($arrDataArtitles);
- // Se guarda el documento y se genera el código del documento
- $arrResponseDocument = $this->resourcesController->saveDocument($base64Document, 'GEAD', $nameDocument, 'IN', $responseData['LINE_NUMBER']);
- if ( $arrResponseDocument['error'] ) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- 'ERR_DOWNLOAD_ARTITLE_DOW008:'.$arrResponseDocument['msg'], $arrResponseDocument['response'],
- 500
- );
- }
- // Se obtiene el código del documento
- $codeDocument = $arrResponseDocument['response'];
- $now = $this->functionsController->now();
- $currentDate = $now->toDateTimeString();
- try {
- $validaeInsert = DB::table('S002V01TPRDO')->insert([
- 'PRDO_NUPR' => $responseData['PROVIDER'],
- 'PRDO_CODU' => $codeDocument,
- 'PRDO_TIPO' => 'IN',
- 'PRDO_DESC' => 'GENERACIÓN DE DOCUMENTO DE ARTÍCULOS POR PROVEEDOR',
- 'PRDO_NULI' => $responseData['LINE_NUMBER'],
- 'PRDO_USRE' => $user,
- 'PRDO_FERE' => $currentDate,
- 'PRDO_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
- ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_DOWNLOAD_ARTITLE_DOW009: Ocurrió un error al registrar el documento.", $th->getMessage(), 500);
- }
- if (!$validaeInsert) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_DOWNLOAD_ARTITLE_DOW010: No se pudo registrar el documento en la base de datos", [], 500);
- }
- DB::commit(); # Para guardar los cambios en la base de datos
- return $this->responseController->makeResponse(false, "ÉXITO: Se genero correctamente.", $codeDocument);
- }
- public function generateSheetProviderXLS($encProvider, $typeUser, $user, $line) {
-
- try {
- $idProvider = $this->encController->decrypt($encProvider);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET000: Ocurrió un error al obtener el número del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- try {
- $user = $this->encController->decrypt($user);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET001: Ocurrió un error al obtener el usuario.",
- $th->getMessage(),
- 500
- );
- }
- if ($typeUser === 'P') {
- try {
- $arrProvider = (array) DB::table('S002V01TPROV')
- ->where('PROV_NUPR', '=', $idProvider)
- ->where('PROV_NULI', '=', $line)
- ->where('REFI_NULI', '=', $line)
- ->where('REFI_ESTA', '=', 'Activo')
- ->join('S002V01TREFI', 'REFI_CRFI', '=', 'PROV_CRFI')
- ->first([
- 'PROV_NUPR',
- 'PROV_IDPS',
- 'PROV_NOCO',
- 'PROV_NOMB',
- 'PROV_APPA',
- 'PROV_APMA',
- 'PROV_CORR',
- 'PROV_LAD1',
- 'PROV_TEL1',
- 'PROV_LAD2',
- 'PROV_TEL2',
- 'PROV_XRFC',
- 'PROV_XTAX',
- 'PROV_TIPO',
- 'PROV_TICO',
- 'PROV_SIWE',
- 'PROV_MEPA',
- 'PROV_CALL',
- 'PROV_NUEX',
- 'PROV_NUIN',
- 'PROV_COPO',
- 'PROV_COLO',
- 'PROV_MUNI',
- 'PROV_LOCA',
- 'PROV_ENTI',
- 'PROV_PAIS',
- 'PROV_ESTA',
- 'PROV_INEX',
- 'PROV_USRE',
- 'PROV_FERE',
- 'PROV_USMO',
- 'PROV_FEMO',
- 'PROV_FEAR',
- 'REFI_CRFI',
- 'REFI_DRFI',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET002: Ocurrió un error al obtener la información del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- } else if ($typeUser === 'S') {
- try {
- $arrProvider = (array) DB::table('S002V01TPROV')
- ->where('PROV_IDPS', '=', $idProvider)
- ->where('PROV_NULI', '=', $line)
- ->where('REFI_NULI', '=', $line)
- ->where('REFI_ESTA', '=', 'Activo')
- ->join('S002V01TREFI', 'REFI_CRFI', '=', 'PROV_CRFI')
- ->first([
- 'PROV_NUPR',
- 'PROV_IDPS',
- 'PROV_NOCO',
- 'PROV_NOMB',
- 'PROV_APPA',
- 'PROV_APMA',
- 'PROV_CORR',
- 'PROV_LAD1',
- 'PROV_TEL1',
- 'PROV_LAD2',
- 'PROV_TEL2',
- 'PROV_XRFC',
- 'PROV_XTAX',
- 'PROV_TIPO',
- 'PROV_TICO',
- 'PROV_SIWE',
- 'PROV_MEPA',
- 'PROV_CALL',
- 'PROV_NUEX',
- 'PROV_NUIN',
- 'PROV_COPO',
- 'PROV_COLO',
- 'PROV_MUNI',
- 'PROV_LOCA',
- 'PROV_ENTI',
- 'PROV_PAIS',
- 'PROV_ESTA',
- 'PROV_INEX',
- 'PROV_USRE',
- 'PROV_FERE',
- 'PROV_USMO',
- 'PROV_FEMO',
- 'PROV_FEAR',
- 'REFI_CRFI',
- 'REFI_DRFI',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET002: Ocurrió un error al obtener la información del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- }
-
- if ( empty($arrProvider) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET003: El proveedor seleccionado no existe.",
- [],
- 500
- );
- }
- if ($arrProvider['PROV_ESTA'] !== 'Activo') {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET004: El proveedor seleccionado no se encuentra activo.",
- [],
- 500
- );
- }
- try {
- $arrReference = DB::table('S002V01TPRRE')
- ->where('PRRE_NUPR', '=', $idProvider)
- ->where('PRRE_NULI', '=', $line)
- ->where('PRRE_ESTA', '=', 'Activo')
- ->get([
- 'PRRE_IDRE',
- 'PRRE_EMPR',
- 'PRRE_CORR',
- 'PRRE_LADA',
- 'PRRE_TELE',
- 'PRRE_XRFC',
- 'PRRE_DIRE',
- ]);
- $arrReference = json_decode( json_encode($arrReference), true );
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET005: Ocurrió un error al obtener las referencias del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- try {
- $arrContact = DB::table('S002V01TPRCO')
- ->where('PRCO_NUPR', '=', $idProvider)
- ->where('PRCO_NULI', '=', $line)
- ->where('PRCO_ESTA', '=', 'Activo')
- ->get([
- 'PRCO_IDCP',
- 'PRCO_NOMB',
- 'PRCO_TIPO',
- 'PRCO_CALL',
- 'PRCO_NUEX',
- 'PRCO_NUIN',
- 'PRCO_COPO',
- 'PRCO_COLO',
- 'PRCO_LOCA',
- 'PRCO_MUNI',
- 'PRCO_ENTI',
- 'PRCO_PAIS',
- 'PRCO_LAD1',
- 'PRCO_TEL1',
- 'PRCO_LAD2',
- 'PRCO_TEL2',
- 'PRCO_COR1',
- 'PRCO_COR2',
- 'PRCO_OBSE',
- ]);
- $arrContact = json_decode( json_encode($arrContact), true );
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET006: Ocurrió un error al obtener los contactos del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- try {
- $arrCondition = DB::table('S002V01TPRCN')
- ->where('PRCN_NUPR', '=', $idProvider)
- ->where('PRCN_NULI', '=', $line)
- ->where('PRCN_ESTA', '=', 'Activo')
- ->get([
- 'PRCN_IDCM',
- 'PRCN_TIPO',
- 'PRCN_INFO',
- ]);
- $arrCondition = json_decode( json_encode($arrCondition), true );
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET007: Ocurrió un error al obtener las condiciones del proveedor.",
- $th->getMessage(),
- 500
- );
- }
-
- try {
- $arrCatalog = DB::table('S002V01TPRCE')
- ->where('PRCE_NUPR', '=', $idProvider)
- ->where('PRCE_NULI', '=', $line)
- ->where('PRCE_ESTA', '=', 'Activo')
- ->get([
- 'PRCE_IDCE',
- 'PRCE_CATA',
- 'PRCE_DESC',
- 'PRCE_XURL',
- ]);
- $arrCatalog = json_decode( json_encode($arrCatalog), true );
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET008: Ocurrió un error al obtener los catálogos del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- try {
- $arrPayment = json_decode($arrProvider['PROV_MEPA']);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET009: El proveedor seleccionado no se encuentra activo.",
- $th->getMessage(),
- 500
- );
- }
- $spreadsheet = new Spreadsheet();
- $activeWorksheet = $spreadsheet->getActiveSheet()->setTitle($arrProvider['PROV_NUPR']);
- $headerA1 = 'Número de Proveedor';
- $contentA1 = $arrProvider['PROV_NUPR'];
- $activeWorksheet->setCellValue("A1", $headerA1);
- $activeWorksheet->setCellValue("B1", $contentA1);
- $activeWorksheet->getStyle( "A1" )->getFont()->setBold(true);
-
- $headerB1 = 'Número de Subcontratista';
- $contentB1 = '';
- if ( $arrProvider['PROV_IDPS'] === null || $arrProvider['PROV_IDPS'] === '' ) {
- $contentB1 = 'Sin Subcontratista';
- } else {
- $contentB1 = $arrProvider['PROV_IDPS'];
- }
- $activeWorksheet->setCellValue("A2", $headerB1);
- $activeWorksheet->setCellValue("B2", $contentB1);
- $activeWorksheet->getStyle( "A2" )->getFont()->setBold(true);
- $headerC1 = "Nombre Comercial";
- $contentC1 = $arrProvider['PROV_NOCO'];
- $activeWorksheet->setCellValue("A3", $headerC1);
- $activeWorksheet->setCellValue("B3", $contentC1);
- $activeWorksheet->getStyle( "A3" )->getFont()->setBold(true);
- $headerD1 = 'Responsable';
- $contentD1 = $arrProvider['PROV_NOMB'].' '.$arrProvider['PROV_APPA'].' '.$arrProvider['PROV_APMA'] === null ? '' : $arrProvider['PROV_APMA'];
- $activeWorksheet->setCellValue("A4", $headerD1);
- $activeWorksheet->setCellValue("B4", $contentD1);
- $activeWorksheet->getStyle( "A4" )->getFont()->setBold(true);
- $headerE1 = 'Correo electrónico';
- $contentE1 = $arrProvider['PROV_CORR'];
- $activeWorksheet->setCellValue("A5", $headerE1);
- $activeWorksheet->setCellValue("B5", $contentE1);
- $activeWorksheet->getStyle( "A5" )->getFont()->setBold(true);
- $headerF1 = '';
- $contentF1 = '';
- if ($arrProvider['PROV_XRFC'] !== null && $arrProvider['PROV_XRFC'] !== '' && ($arrProvider['PROV_XTAX'] === '' || $arrProvider['PROV_XTAX'] === null)) {
- $headerF1 = 'R.F.C';
- $contentF1 = $arrProvider['PROV_XRFC'];
- } else if ($arrProvider['PROV_XTAX'] !== null && $arrProvider['PROV_XTAX'] !== '' && ($arrProvider['PROV_XRFC'] === '' || $arrProvider['PROV_XRFC'] === null)) {
- $headerF1 = 'TAX ID';
- $contentF1 = $arrProvider['PROV_XTAX'];
- } else {
- $headerF1 = 'R.F.C / TAX ID';
- $contentF1 = 'Sin contenido';
- }
- $activeWorksheet->setCellValue("A6", $headerF1);
- $activeWorksheet->setCellValue("B6", $contentF1);
- $activeWorksheet->getStyle( "A6" )->getFont()->setBold(true);
- $headerF1 = 'Régimen fiscal';
- $contentF1 = $arrProvider['REFI_DRFI'] . ' (' . $arrProvider['REFI_CRFI'] . ')';
- $activeWorksheet->setCellValue("A7", "Régimen Fiscal");
- $activeWorksheet->setCellValue("B7", $contentF1);
- $activeWorksheet->getStyle( "A7" )->getFont()->setBold(true);
- $headerH1 = 'Tipo de ciudadania';
- $contentH1 = $arrProvider['PROV_TIPO'];
- $activeWorksheet->setCellValue("A8", $headerH1);
- $activeWorksheet->setCellValue("B8", $contentH1);
- $activeWorksheet->getStyle( "A9" )->getFont()->setBold(true);
- $headerI1 = 'Tipo de contribuyente';
- $contentI1 = $arrProvider['PROV_TICO'];
- $activeWorksheet->setCellValue("A9", $headerI1);
- $activeWorksheet->setCellValue("B9", $contentI1);
- $activeWorksheet->getStyle( "A9" )->getFont()->setBold(true);
- $headerJ1 = 'Teléfono principal';
- $contentJ1 = '('.$arrProvider['PROV_LAD1'] .') '. $arrProvider['PROV_TEL1'];
- $activeWorksheet->setCellValue("A10", $headerJ1);
- $activeWorksheet->setCellValue("B10", $contentJ1);
- $activeWorksheet->getStyle( "A10" )->getFont()->setBold(true);
- $headerK1 = 'Teléfono secundario';
- $contentK1 = '';
- if ($arrProvider['PROV_LAD2'] !== null && $arrProvider['PROV_LAD2'] !== '' && $arrProvider['PROV_TEL2'] !== null && $arrProvider['PROV_TEL2'] !== '') {
- $contentK1 = '('.$arrProvider['PROV_LAD2'] .') '. $arrProvider['PROV_TEL2'];
- } else {
- $contentK1 = 'No aplica';
- }
- $activeWorksheet->setCellValue("A11", $headerK1);
- $activeWorksheet->setCellValue("B11", $contentK1);
- $activeWorksheet->getStyle( "A11" )->getFont()->setBold(true);
- $headerL1 = 'Enlace de sitio web';
- $contentL1 = '';
- if ($arrProvider['PROV_SIWE'] !== null && $arrProvider['PROV_SIWE'] !== '') {
- $contentL1 = $arrProvider['PROV_SIWE'];
- } else {
- $contentL1 = 'No aplica';
- }
- $activeWorksheet->setCellValue("A12", $headerL1);
- $activeWorksheet->setCellValue("B12", $contentL1);
- $activeWorksheet->getStyle( "A12" )->getFont()->setBold(true);
- $headerM1 = 'Calle ';
- $contentM1 = $arrProvider['PROV_CALL'];
- $activeWorksheet->setCellValue("A13", $headerM1);
- $activeWorksheet->setCellValue("B13", $contentM1);
- $activeWorksheet->getStyle( "A13" )->getFont()->setBold(true);
- $headerN1 = 'Número exterior';
- $contentN1 = $arrProvider['PROV_NUEX'];
- $activeWorksheet->setCellValue("A14", $headerN1);
- $activeWorksheet->setCellValue("B14", $contentN1);
- $activeWorksheet->getStyle( "A14" )->getFont()->setBold(true);
- $headerO1 = 'Número interior';
- $contentO1 = '';
- if ($arrProvider['PROV_NUIN'] !== null && $arrProvider['PROV_NUIN'] !== '') {
- $contentO1 = $arrProvider['PROV_NUIN'];
- } else {
- $contentO1 = 'No aplica';
- }
- $activeWorksheet->setCellValue("A15", $headerO1);
- $activeWorksheet->setCellValue("B15", $contentO1);
- $activeWorksheet->getStyle( "A15" )->getFont()->setBold(true);
- $headerP1 = 'Código postal';
- $contentP1 = $arrProvider['PROV_COPO'];
- $activeWorksheet->setCellValue("A16", $headerP1);
- $activeWorksheet->setCellValue("B16", $contentP1);
- $activeWorksheet->getStyle( "A16" )->getFont()->setBold(true);
- $headerQ1 = 'Colonia';
- if ($arrProvider['PROV_PAIS'] === 'MEX') {
- try {
- $arrColony = (array) DB::table('S002V01TCOLO')
- ->where('COLO_NULI', '=', $line)
- ->where('COLO_COCO', '=', $arrProvider['PROV_COLO'])
- ->where('COLO_COPO', '=', $arrProvider['PROV_COPO'])
- ->where('COLO_ESTA', '=', 'Activo')
- ->first([ 'COLO_COCO', 'COLO_NOCO' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET010: Ocurrió un error al obtener la información de la colonia.",
- $th->getMessage(),
- 500
- );
- }
- if ( empty($arrColony) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET011: No se encontró la colonia asociada al proveedor.",
- [],
- 500
- );
- }
- $contentQ1 = $arrColony['COLO_NOCO'] . ' (' . $arrColony['COLO_COCO'] . ')';
- } else {
- $contentQ1 = $arrProvider['PROV_COLO'];
- }
- $activeWorksheet->setCellValue("A17", $headerQ1);
- $activeWorksheet->setCellValue("B17", $contentQ1);
- $activeWorksheet->getStyle( "A17" )->getFont()->setBold(true);
- $headerR1 = 'Localidad';
- $contentR1 = '';
- if ($arrProvider['PROV_PAIS'] === 'MEX') {
- if ( !is_null($arrProvider['PROV_LOCA']) && !empty($arrProvider['PROV_LOCA']) ) {
- try {
- $arrLocate = (array) DB::table('S002V01TLOCA')
- ->where('LOCA_NULI', '=', $line)
- ->where('LOCA_COLO', '=', $arrProvider['PROV_LOCA'])
- ->where('LOCA_COES', '=', $arrProvider['PROV_ENTI'])
- ->where('LOCA_ESTA', '=', 'Activo')
- ->first([ 'LOCA_COLO', 'LOCA_NOLO' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET012: Ocurrió un error al obtener la información de la localidad.",
- $th->getMessage(),
- 500
- );
- }
- if ( empty($arrLocate) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET013: No se encontró la localidad asociada al proveedor.",
- [],
- 500
- );
- }
- $contentR1 = $arrLocate['LOCA_NOLO'] . ' (' . $arrLocate['LOCA_NOLO'] . ')';
- } else {
- $contentR1 = 'Sin localidad';
- }
- } else {
- if ( !is_null($arrProvider['PROV_LOCA']) && !empty($arrProvider['PROV_LOCA']) ) {
- $contentR1 = $arrProvider['PROV_LOCA'];
- } else {
- $contentR1 = 'Sin localidad';
- }
- }
- $activeWorksheet->setCellValue("A18", $headerR1);
- $activeWorksheet->setCellValue("B18", $contentR1);
- $activeWorksheet->getColumnDimension("R")->setAutoSize(true);
- $activeWorksheet->getStyle( "A18" )->getFont()->setBold(true);
- $headerS1 = 'Municipio';
- $contentS1 = '';
- if ($arrProvider['PROV_PAIS'] === 'MEX') {
- try {
- $arrMunicipality = (array) DB::table('S002V01TMUNI')
- ->where('MUNI_NULI', '=', $line)
- ->where('MUNI_COMU', '=', $arrProvider['PROV_MUNI'])
- ->where('MUNI_COES', '=', $arrProvider['PROV_ENTI'])
- ->where('MUNI_ESTA', '=', 'Activo')
- ->first([ 'MUNI_COMU', 'MUNI_NOMU' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET014: Ocurrió un error al obtener la información del municipio.",
- $th->getMessage(),
- 500
- );
- }
- if ( empty($arrMunicipality) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET015: No se encontró el municipio asociada al proveedor.",
- [],
- 500
- );
- }
- $contentS1 = $arrMunicipality['MUNI_NOMU'] . ' (' . $arrMunicipality['MUNI_COMU'] . ')';
- } else {
- $contentS1 = $arrProvider['PROV_MUNI'];
- }
- $activeWorksheet->setCellValue("A19", $headerS1);
- $activeWorksheet->setCellValue("B19", $contentS1);
- $activeWorksheet->getStyle( "A19" )->getFont()->setBold(true);
- $headerT1 = 'Entidad Federativa';
- $contentT1 = '';
- if ($arrProvider['PROV_PAIS'] === 'MEX') {
- try {
- $arrEntity = (array) DB::table('S002V01TESTA')
- ->where('ESTA_NULI', '=', $line)
- ->where('ESTA_COES', '=', $arrProvider['PROV_ENTI'])
- ->where('ESTA_COPA', '=', $arrProvider['PROV_PAIS'])
- ->where('ESTA_ESTA', '=', 'Activo')
- ->first([ 'ESTA_COES', 'ESTA_NOES' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET016: Ocurrió un error al obtener la información de la entidad federativa.",
- $th->getMessage(),
- 500
- );
- }
- if ( empty($arrEntity) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET017: No se encontró la entidad federativa asociada al proveedor.",
- [],
- 500
- );
- }
- $contentT1 = $arrEntity['ESTA_NOES'] . ' (' . $arrEntity['ESTA_COES'] . ')';
- } else {
- $contentT1 = $arrProvider['PROV_ENTI'];
- }
- $activeWorksheet->setCellValue("A20", $headerT1);
- $activeWorksheet->setCellValue("B20", $contentT1);
- $activeWorksheet->getStyle( "A20" )->getFont()->setBold(true);
-
- $headerU1 = 'País';
- try {
- $arrCountry = (array) DB::table('S002V01TPAIS')
- ->where('PAIS_NULI', '=', $line)
- ->where('PAIS_IDPA', '=', $arrProvider['PROV_PAIS'])
- ->first([ 'PAIS_IDPA', 'PAIS_NOMB' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET018: Ocurrió un error al obtener la información del país.",
- $th->getMessage(),
- 500
- );
- }
- if ( empty($arrCountry) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET019: No se encontró el país asociado al proveedor.",
- [],
- 500
- );
- }
- $contentU1 = $arrCountry['PAIS_NOMB'] . ' (' . $arrCountry['PAIS_IDPA'] . ')';
- $activeWorksheet->setCellValue("A21", $headerU1);
- $activeWorksheet->setCellValue("B21", $contentU1);
- $activeWorksheet->getStyle( "A21" )->getFont()->setBold(true);
- $activeWorksheet->getColumnDimension("A")->setAutoSize(true);
- $activeWorksheet->getColumnDimension("B")->setAutoSize(true);
- $arrAlphabet = $this->resourcesController->arrAlphabet;
- $spreadsheet->createSheet();
- $spreadsheet->setActiveSheetIndex(1);
- $activeWorksheetContact = $spreadsheet->getActiveSheet()->setTitle('Contactos');
- $arrHeaderContact = array(
- 'ID', // A
- 'Contacto', // B
- 'Tipo de Contacto', // C
- 'Correo Electrónico Principal', // D
- 'Correo Electrónico Secundario', // E
- 'Teléfono Principal', // F
- 'Teléfono Secundario', // G
- 'Calle', // H
- 'Número Exterior', // I
- 'Numero Interior', // J
- 'Código Postal', // K
- 'Colonia', // L
- 'Localidad', // M
- 'Municipio', // N
- 'Entidad Federativa', // O
- 'País', // P
- 'Observaciones' // Q
- );
- foreach ($arrContact as $key => $contact) {
- $key = $key + 2;
- $activeWorksheetContact->setCellValue("A".$key, $contact['PRCO_IDCP']);
- $activeWorksheetContact->setCellValue("B".$key, $contact['PRCO_NOMB']);
- $activeWorksheetContact->setCellValue("C".$key, $contact['PRCO_TIPO']);
- $activeWorksheetContact->setCellValue("D".$key, $contact['PRCO_COR1']);
- if ( !is_null( $contact['PRCO_COR2'] ) ) {
- $activeWorksheetContact->setCellValue("E".$key, $contact['PRCO_COR2']);
- } else {
- $activeWorksheetContact->setCellValue("E".$key, 'No aplica' );
- }
- $activeWorksheetContact->setCellValue("F".$key, $contact['PRCO_LAD1'] . ' ' . $contact['PRCO_TEL1'] );
- if ( !is_null( $contact['PRCO_LAD2'] ) && !is_null( $contact['PRCO_TEL2'] ) ) {
- $activeWorksheetContact->setCellValue("G".$key, $contact['PRCO_LAD2'] . ' ' . $contact['PRCO_TEL2'] );
- } else {
- $activeWorksheetContact->setCellValue("G".$key, 'No aplica' );
- }
- $activeWorksheetContact->setCellValue("H".$key, $contact['PRCO_CALL'] );
- $activeWorksheetContact->setCellValue("I".$key, $contact['PRCO_NUEX'] );
- if ( !is_null( $contact['PRCO_NUIN'] ) ) {
- $activeWorksheetContact->setCellValue("J".$key, $contact['PRCO_NUIN']);
- } else {
- $activeWorksheetContact->setCellValue("J".$key, 'No aplica' );
- }
- $activeWorksheetContact->setCellValue("K".$key, $contact['PRCO_COPO'] );
- $activeWorksheetContact->setCellValue("L".$key, $contact['PRCO_COLO'] );
- if ( !is_null($contact['PRCO_LOCA']) && $contact['PRCO_LOCA'] !== 'Sin localidad' ) {
- $activeWorksheetContact->setCellValue("M".$key, $contact['PRCO_LOCA'] );
- } else {
- $activeWorksheetContact->setCellValue("M".$key, 'No aplica' );
- }
- $activeWorksheetContact->setCellValue("N".$key, $contact['PRCO_MUNI'] );
- $activeWorksheetContact->setCellValue("O".$key, $contact['PRCO_ENTI'] );
- $activeWorksheetContact->setCellValue("P".$key, $contact['PRCO_PAIS'] );
- $activeWorksheetContact->setCellValue("Q".$key, $contact['PRCO_OBSE'] );
- }
- foreach ($arrHeaderContact as $keyHeaderContact => $headerContact) {
- $activeWorksheetContact->setCellValue( $arrAlphabet[$keyHeaderContact]."1", $headerContact);
- $activeWorksheetContact->getColumnDimension( $arrAlphabet[$keyHeaderContact] )->setAutoSize(true);
- $activeWorksheetContact->getStyle( $arrAlphabet[$keyHeaderContact]."1" )->getFont()->setBold(true);
- }
- $spreadsheet->createSheet();
- $spreadsheet->setActiveSheetIndex(2);
- $activeWorksheetReference = $spreadsheet->getActiveSheet()->setTitle('Referencias');
- $arrHeaderReference = array(
- 'ID', // A
- 'Empresa', // B
- 'R.F.C.', // C
- 'Correo', // D
- 'Teléfono', // E
- 'Dirección', // F
- );
- foreach ($arrReference as $key => $reference) {
- $key = $key + 2;
- $activeWorksheetReference->setCellValue("A".$key, $reference['PRRE_IDRE']);
- $activeWorksheetReference->setCellValue("B".$key, $reference['PRRE_EMPR']);
- $activeWorksheetReference->setCellValue("C".$key, $reference['PRRE_XRFC']);
- $activeWorksheetReference->setCellValue("D".$key, $reference['PRRE_CORR']);
- $activeWorksheetReference->setCellValue("E".$key, $reference['PRRE_LADA'] .' '. $reference['PRRE_TELE']);
- $activeWorksheetReference->setCellValue("F".$key, $reference['PRRE_DIRE']);
- }
- foreach ($arrHeaderReference as $keyHeaderReference => $headerReference) {
- $activeWorksheetReference->setCellValue( $arrAlphabet[$keyHeaderReference]."1", $headerReference);
- $activeWorksheetReference->getColumnDimension( $arrAlphabet[$keyHeaderReference] )->setAutoSize(true);
- $activeWorksheetReference->getStyle( $arrAlphabet[$keyHeaderReference]."1" )->getFont()->setBold(true);
- }
- $spreadsheet->createSheet();
- $spreadsheet->setActiveSheetIndex(3);
- $activeWorksheetCatalog = $spreadsheet->getActiveSheet()->setTitle('Catálogos');
- $arrHeaderCatalog = array(
- 'ID', // A
- 'Catálogo', // B
- 'Descripción', // C
- 'URL', // D
- );
- foreach ($arrCatalog as $key => $catalog) {
- $key = $key + 2;
- $activeWorksheetCatalog->setCellValue("A".$key, $catalog['PRCE_IDCE']);
- $activeWorksheetCatalog->setCellValue("B".$key, $catalog['PRCE_CATA']);
- $activeWorksheetCatalog->setCellValue("C".$key, $catalog['PRCE_DESC']);
- $activeWorksheetCatalog->setCellValue("D".$key, $catalog['PRCE_XURL']);
- }
- foreach ($arrHeaderCatalog as $keyHeaderCatalog => $headerCatalog) {
- $activeWorksheetCatalog->setCellValue( $arrAlphabet[$keyHeaderCatalog]."1", $headerCatalog);
- $activeWorksheetCatalog->getColumnDimension( $arrAlphabet[$keyHeaderCatalog] )->setAutoSize(true);
- $activeWorksheetCatalog->getStyle( $arrAlphabet[$keyHeaderCatalog]."1" )->getFont()->setBold(true);
- }
- $spreadsheet->createSheet();
- $spreadsheet->setActiveSheetIndex(4);
- $activeWorksheetPayment = $spreadsheet->getActiveSheet()->setTitle('Métodos de Pago');
- $arrHeaderPayment = array(
- 'ID', // A
- 'Método de Pago', // B
- );
- $cont = 2;
- foreach ($arrPayment as $key => $payment) {
- $activeWorksheetPayment->setCellValue("A".$cont, $key);
- $activeWorksheetPayment->setCellValue("B".$cont, $payment);
- $cont++;
- }
- foreach ($arrHeaderPayment as $keyHeaderPayment => $headerPayment) {
- $activeWorksheetPayment->setCellValue( $arrAlphabet[$keyHeaderPayment]."1", $headerPayment);
- $activeWorksheetPayment->getColumnDimension( $arrAlphabet[$keyHeaderPayment] )->setAutoSize(true);
- $activeWorksheetPayment->getStyle( $arrAlphabet[$keyHeaderPayment]."1" )->getFont()->setBold(true);
- }
- $spreadsheet->createSheet();
- $spreadsheet->setActiveSheetIndex(5);
- $activeWorksheetCondition = $spreadsheet->getActiveSheet()->setTitle('Condiciones');
- $arrHeaderCondition = array(
- 'ID', // A
- 'Tipo de Condición', // B
- 'Información', // C
- );
- foreach ($arrCondition as $key => $condition) {
- $key = $key + 2;
- $activeWorksheetCondition->setCellValue("A".$key, $condition['PRCN_IDCM']);
- $activeWorksheetCondition->setCellValue("B".$key, $condition['PRCN_TIPO']);
- $activeWorksheetCondition->setCellValue("C".$key, $condition['PRCN_INFO']);
- }
- foreach ($arrHeaderCondition as $keyHeaderCondition => $headerCondition) {
- $activeWorksheetCondition->setCellValue( $arrAlphabet[$keyHeaderCondition]."1", $headerCondition);
- $activeWorksheetCondition->getColumnDimension( $arrAlphabet[$keyHeaderCondition] )->setAutoSize(true);
- $activeWorksheetCondition->getStyle( $arrAlphabet[$keyHeaderCondition]."1" )->getFont()->setBold(true);
- }
- $nuli = $this->resourcesController->formatSecuence($line, 2);
- $como = 'GEAD'; // Código del módulo
- $cldo = 'IN'; // Código de la clasificación
- $fecr = date('ymd'); // Fecha en la se carga el archivo
- try {
- $arrSecuence = (array) DB::table('S002V01TAFAL')
- ->where('AFAL_COMO', '=', $como)
- ->where('AFAL_CLDO', '=', $cldo)
- ->where('AFAL_NULI', '=', $line)
- ->orderBy('AFAL_NUSE', 'desc')
- ->first([ 'AFAL_NUSE' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET020: Ocurrió un error al obtener la información de la secuencia.",
- $th->getMessage(),
- 500
- );
- }
- $nuse = 1; // Secuencia del documento
- if ( !empty( $arrSecuence ) && !is_null( $arrSecuence ) ) {
- $nuse = intval( $arrSecuence['AFAL_NUSE'] ) + 1;
- }
- $nuse = $this->resourcesController->formatSecuence($nuse, 6);
- $nuve = $this->resourcesController->formatSecuence('1', 2);
- $noar = 'ficha_de_proveedor_' . $arrProvider['PROV_NUPR'];
- $exte = 'xlsx';
- if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
- $filePath = 'C:/ITTEC/SAM/Dev/SistemaMantenimiento/sistema-mantenimiento-back/public/public_files/'; // API JEAN
- } else {
- $filePath = $this->functionsController->getApiURI().'public_files/'; // API QA
- }
- $fileName = $nuli.'-'.$como.'-'.$cldo.'-'.$fecr.'-'.$nuse.'='.$nuve.'='.$noar.'.'.$exte;
- $tempFile = $filePath.$fileName;
- if ( file_exists( $tempFile ) ) {
- if ( !unlink( $tempFile ) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET021: Ocurrió un error al eliminar el siguiente archivo: " . $tempFile,
- [],
- 500
- );
- }
- }
-
- try {
- $writer = new Xlsx($spreadsheet);
- ob_start();
- $writer->save('php://output');
- $base64 = base64_encode(ob_get_clean());
- $validate = \File::put( $tempFile, base64_decode($base64));
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET022: Ocurrió un error al guardar el documento.",
- $th->getMessage(),
- 500
- );
- }
- $ubic = Storage::putFile('files', new File($tempFile));
- $ubic = str_replace("/", "\\", $ubic);
- $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
- $tama = filesize($ubic);
- $usac = json_encode([$user]);
- $now = $this->functionsController->now();
- $currentDate = $now->toDateTimeString();
- try {
- $validateInsert = DB::table('S002V01TAFAL')->insert([
- 'AFAL_NULI' => $line,
- 'AFAL_COMO' => $como,
- 'AFAL_CLDO' => $cldo,
- 'AFAL_FECR' => $fecr,
- 'AFAL_NUSE' => $nuse,
- 'AFAL_NUVE' => $nuve,
- 'AFAL_NOAR' => $noar,
- 'AFAL_EXTE' => $exte,
- 'AFAL_TAMA' => $tama,
- 'AFAL_UBIC' => $ubic,
- 'AFAL_USAC' => $usac,
- 'AFAL_USRE' => $user,
- 'AFAL_FERE' => $currentDate,
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET023: Ocurrió un error guardar los datos a la tabla final de archivos.",
- $th->getMessage(),
- 500
- );
- }
- if ( !$validateInsert ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET024: No se pudo guardar la ficha del proveedor en la base de datos.",
- [],
- 500
- );
- }
-
- $urlPublic = 'http://192.168.100.105:8000/public_files/' . $fileName;
- return $this->responseController->makeResponse(false, "EXITO: Modificación Exitosa", [ 'url' => $urlPublic ]);
- }
- public function generateSheetProviderPDF($encProvider, $typeUser, $user, $line) {
- try {
- $idProvider = $this->encController->decrypt($encProvider);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET000: Ocurrió un error al obtener el número del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- try {
- $user = $this->encController->decrypt($user);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET001: Ocurrió un error al obtener el usuario.",
- $th->getMessage(),
- 500
- );
- }
- $arrProvider = [];
- if ($typeUser === 'P') {
- try {
- $arrProvider = (array) DB::table('S002V01TPROV')
- ->where('PROV_NUPR', '=', $idProvider)
- ->where('PROV_NULI', '=', $line)
- ->where('REFI_NULI', '=', $line)
- ->where('REFI_ESTA', '=', 'Activo')
- ->join('S002V01TREFI', 'REFI_CRFI', '=', 'PROV_CRFI')
- ->first([
- 'PROV_NUPR',
- 'PROV_IDPS',
- 'PROV_NOCO',
- // 'PROV_CRFI',
- 'PROV_NOMB',
- 'PROV_APPA',
- 'PROV_APMA',
- 'PROV_CORR',
- 'PROV_LAD1',
- 'PROV_TEL1',
- 'PROV_LAD2',
- 'PROV_TEL2',
- 'PROV_XRFC',
- 'PROV_XTAX',
- 'PROV_TIPO',
- 'PROV_TICO',
- 'PROV_SIWE',
- 'PROV_MEPA',
- 'PROV_CALL',
- 'PROV_NUEX',
- 'PROV_NUIN',
- 'PROV_COPO',
- 'PROV_COLO',
- 'PROV_MUNI',
- 'PROV_LOCA',
- 'PROV_ENTI',
- 'PROV_PAIS',
- 'PROV_ESTA',
- 'PROV_INEX',
- 'PROV_USRE',
- 'PROV_FERE',
- 'PROV_USMO',
- 'PROV_FEMO',
- 'PROV_FEAR',
- 'REFI_CRFI',
- 'REFI_DRFI',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET002: Ocurrió un error al obtener la información del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- } else if ($typeUser === 'S') {
- try {
- $arrProvider = (array) DB::table('S002V01TPROV')
- ->where('PROV_IDPS', '=', $idProvider)
- ->where('PROV_NULI', '=', $line)
- ->where('REFI_NULI', '=', $line)
- ->where('REFI_ESTA', '=', 'Activo')
- ->join('S002V01TREFI', 'REFI_CRFI', '=', 'PROV_CRFI')
- ->first([
- 'PROV_NUPR',
- 'PROV_IDPS',
- 'PROV_NOCO',
- // 'PROV_CRFI',
- 'PROV_NOMB',
- 'PROV_APPA',
- 'PROV_APMA',
- 'PROV_CORR',
- 'PROV_LAD1',
- 'PROV_TEL1',
- 'PROV_LAD2',
- 'PROV_TEL2',
- 'PROV_XRFC',
- 'PROV_XTAX',
- 'PROV_TIPO',
- 'PROV_TICO',
- 'PROV_SIWE',
- 'PROV_MEPA',
- 'PROV_CALL',
- 'PROV_NUEX',
- 'PROV_NUIN',
- 'PROV_COPO',
- 'PROV_COLO',
- 'PROV_MUNI',
- 'PROV_LOCA',
- 'PROV_ENTI',
- 'PROV_PAIS',
- 'PROV_ESTA',
- 'PROV_INEX',
- 'PROV_USRE',
- 'PROV_FERE',
- 'PROV_USMO',
- 'PROV_FEMO',
- 'PROV_FEAR',
- 'REFI_CRFI',
- 'REFI_DRFI',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET002: Ocurrió un error al obtener la información del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- }
- if ( empty($arrProvider) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET003: El proveedor seleccionado no existe.",
- [],
- 500
- );
- }
- if ($arrProvider['PROV_ESTA'] !== 'Activo') {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET004: El proveedor seleccionado no se encuentra activo.",
- [],
- 500
- );
- }
- try {
- $arrReference = DB::table('S002V01TPRRE')
- ->where('PRRE_NUPR', '=', $idProvider)
- ->where('PRRE_NULI', '=', $line)
- ->where('PRRE_ESTA', '=', 'Activo')
- ->get([
- 'PRRE_IDRE',
- 'PRRE_EMPR',
- 'PRRE_CORR',
- 'PRRE_LADA',
- 'PRRE_TELE',
- 'PRRE_XRFC',
- 'PRRE_DIRE',
- ]);
- $arrReference = json_decode( json_encode($arrReference), true );
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET005: Ocurrió un error al obtener las referencias del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- try {
- $arrContact = DB::table('S002V01TPRCO')
- ->where('PRCO_NUPR', '=', $idProvider)
- ->where('PRCO_NULI', '=', $line)
- ->where('PRCO_ESTA', '=', 'Activo')
- ->get([
- 'PRCO_IDCP',
- 'PRCO_NOMB',
- 'PRCO_TIPO',
- 'PRCO_CALL',
- 'PRCO_NUEX',
- 'PRCO_NUIN',
- 'PRCO_COPO',
- 'PRCO_COLO',
- 'PRCO_LOCA',
- 'PRCO_MUNI',
- 'PRCO_ENTI',
- 'PRCO_PAIS',
- 'PRCO_LAD1',
- 'PRCO_TEL1',
- 'PRCO_LAD2',
- 'PRCO_TEL2',
- 'PRCO_COR1',
- 'PRCO_COR2',
- 'PRCO_OBSE',
- ]);
- $arrContact = json_decode( json_encode($arrContact), true );
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET006: Ocurrió un error al obtener los contactos del proveedor.",
- $th->getMessage(),
- 500
- );
- }
-
- try {
- $arrCondition = DB::table('S002V01TPRCN')
- ->where('PRCN_NUPR', '=', $idProvider)
- ->where('PRCN_NULI', '=', $line)
- ->where('PRCN_ESTA', '=', 'Activo')
- ->get([
- 'PRCN_IDCM',
- 'PRCN_TIPO',
- 'PRCN_INFO',
- ]);
- $arrCondition = json_decode( json_encode($arrCondition), true );
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET007: Ocurrió un error al obtener las condiciones del proveedor.",
- $th->getMessage(),
- 500
- );
- }
-
- try {
- $arrCatalog = DB::table('S002V01TPRCE')
- ->where('PRCE_NUPR', '=', $idProvider)
- ->where('PRCE_NULI', '=', $line)
- ->where('PRCE_ESTA', '=', 'Activo')
- ->get([
- 'PRCE_IDCE',
- 'PRCE_CATA',
- 'PRCE_DESC',
- 'PRCE_XURL',
- ]);
- $arrCatalog = json_decode( json_encode($arrCatalog), true );
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET008: Ocurrió un error al obtener los catálogos del proveedor.",
- $th->getMessage(),
- 500
- );
- }
- try {
- $arrPayment = json_decode($arrProvider['PROV_MEPA']);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET009: El proveedor seleccionado no se encuentra activo.",
- $th->getMessage(),
- 500
- );
- }
- $arrProvider['CONDITION'] = $arrCondition;
- $arrProvider['CATALOG'] = $arrCatalog;
- $arrProvider['PROV_MEPA'] = $arrPayment;
- $html = '<!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- body {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 8pt;
- }
- .section-title {
- margin: 20px 0;
- font-size: 12pt;
- }
- table {
- width: 100%;
- }
- thead tr th {
- text-align: start;
- padding: 0 16px;
- height: 52px;
- border-bottom-width: 1px;
- border-bottom-style: solid;
- border-bottom-color: #CCC;
- }
- tbody tr td {
- padding: 0 16px;
- height: 52px;
- border-bottom-width: 1px;
- border-bottom-style: solid;
- border-bottom-color: #CCC;
- }
- p {
- text-align: justify;
- }
- </style>
- </head>
- <body>
- <div class="item">
- <b>Número Proveedor:</b>
- <span>'.$arrProvider['PROV_NUPR'].'</span>
- </div>
- <div class="item">
- <b>Nombre Comercial: </b>
- <span>'.$arrProvider['PROV_NOCO'].'</span>
- </div>
- <div class="item">
- <b>Responsable: </b>
- <span>'.$arrProvider['PROV_NOMB'].' '.$arrProvider['PROV_APPA'].' '.$arrProvider['PROV_APMA'].'</span>
- </div>
- <div class="item">
- <b>Correo electrónico: </b>
- <span>'.$arrProvider['PROV_CORR'].'</span>
- </div>';
-
- if ($arrProvider['PROV_XRFC'] !== null && $arrProvider['PROV_XRFC'] !== '' && ($arrProvider['PROV_XTAX'] === '' || $arrProvider['PROV_XTAX'] === null)) {
- $html.='<div class="item">
- <b>R.F.C: </b>
- <span>'.$arrProvider['PROV_XRFC'].'</span>
- </div>';
- } else if ($arrProvider['PROV_XTAX'] !== null && $arrProvider['PROV_XTAX'] !== '' && ($arrProvider['PROV_XRFC'] === '' || $arrProvider['PROV_XRFC'] === null)) {
- $html.='<div class="item">
- <b>TAX ID: </b>
- <span>'.$arrProvider['PROV_XTAX'].'</span>
- </div>';
- } else {
- $html.='<div class="item">
- <b>R.F.C / TAX ID: </b>
- <span> Sin contenido </span>
- </div>';
- }
- $html.='<div class="item">
- <b>Régimen fiscal: </b>
- <span>'.$arrProvider['REFI_DRFI'] . ' (' . $arrProvider['REFI_CRFI'] . ')'.'</span>
- </div>
- <div class="item">
- <b>Tipo de ciudadania: </b>
- <span>'.$arrProvider['PROV_TIPO'].'</span>
- </div>
- <div class="item">
- <b>Tipo de contribuyente: </b>
- <span>'.$arrProvider['PROV_TICO'].'</span>
- </div>
- <div class="item">
- <b>Teléfono principal: </b>
- <span>'.'('.$arrProvider['PROV_LAD1'] .') '. $arrProvider['PROV_TEL1'].'</span>
- </div>';
-
- if ($arrProvider['PROV_LAD2'] !== null && $arrProvider['PROV_LAD2'] !== '' && $arrProvider['PROV_TEL2'] !== null && $arrProvider['PROV_TEL2'] !== '') {
- $html.='<div class="item">
- <b>Teléfono secundario: </b>
- <span>'.'('.$arrProvider['PROV_LAD2'] .') '. $arrProvider['PROV_TEL2'].'</span>
- </div>';
- } else {
- $html.='<div class="item">
- <b>Teléfono secundario: </b>
- <span>No aplica</span>
- </div>';
- }
- if ($arrProvider['PROV_SIWE'] !== null && $arrProvider['PROV_SIWE'] !== '') {
- $html.='<div class="item">
- <b>Enlace de sitio web: </b>
- <span>'.$arrProvider['PROV_SIWE'].'</span>
- </div>';
- } else {
- $html.='<div class="item">
- <b>Enlace de sitio web: </b>
- <span>No aplica</span>
- </div>';
- }
- $address = $arrProvider['PROV_CALL'].' '.$arrProvider['PROV_NUEX'] . ' ';
- if ($arrProvider['PROV_NUIN'] !== null && $arrProvider['PROV_NUIN'] !== '') {
- $address .= $arrProvider['PROV_NUIN'] . ' ';
- }
- $address .= $arrProvider['PROV_COPO'] . ', ';
- if ($arrProvider['PROV_PAIS'] === 'MEX') {
- try {
- $arrColony = (array) DB::table('S002V01TCOLO')
- ->where('COLO_NULI', '=', $line)
- ->where('COLO_COCO', '=', $arrProvider['PROV_COLO'])
- ->where('COLO_COPO', '=', $arrProvider['PROV_COPO'])
- ->where('COLO_ESTA', '=', 'Activo')
- ->first([ 'COLO_COCO', 'COLO_NOCO' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET010: Ocurrió un error al obtener la información de la colonia.",
- $th->getMessage(),
- 500
- );
- }
- if ( empty($arrColony) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET011: No se encontró la colonia asociada al proveedor.",
- [],
- 500
- );
- }
- $address .= $arrColony['COLO_NOCO'] . ', ';
- } else {
- $address .= $arrProvider['PROV_COLO'] . ', ';
- }
-
- if ($arrProvider['PROV_PAIS'] === 'MEX') {
- if ( !is_null($arrProvider['PROV_LOCA']) && !empty($arrProvider['PROV_LOCA']) ) {
- try {
- $arrLocate = (array) DB::table('S002V01TLOCA')
- ->where('LOCA_NULI', '=', $line)
- ->where('LOCA_COLO', '=', $arrProvider['PROV_LOCA'])
- ->where('LOCA_COES', '=', $arrProvider['PROV_ENTI'])
- ->where('LOCA_ESTA', '=', 'Activo')
- ->first([ 'LOCA_COLO', 'LOCA_NOLO' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET012: Ocurrió un error al obtener la información de la localidad.",
- $th->getMessage(),
- 500
- );
- }
-
- if ( empty($arrLocate) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET013: No se encontró la localidad asociada al proveedor.",
- [],
- 500
- );
- }
-
- $address .= $arrLocate['LOCA_NOLO'] . ', ';
- }
- } else {
- if ( !is_null($arrProvider['PROV_LOCA']) && !empty($arrProvider['PROV_LOCA']) ) {
- $address .= $arrProvider['PROV_LOCA'] . ', ';
- }
- }
-
- if ($arrProvider['PROV_PAIS'] === 'MEX') {
- try {
- $arrMunicipality = (array) DB::table('S002V01TMUNI')
- ->where('MUNI_NULI', '=', $line)
- ->where('MUNI_COMU', '=', $arrProvider['PROV_MUNI'])
- ->where('MUNI_COES', '=', $arrProvider['PROV_ENTI'])
- ->where('MUNI_ESTA', '=', 'Activo')
- ->first([ 'MUNI_COMU', 'MUNI_NOMU' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET014: Ocurrió un error al obtener la información del municipio.",
- $th->getMessage(),
- 500
- );
- }
- if ( empty($arrMunicipality) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET015: No se encontró el municipio asociada al proveedor.",
- [],
- 500
- );
- }
- $address .= $arrMunicipality['MUNI_NOMU'] . ', ';
- } else {
- $address .= $arrProvider['PROV_MUNI'] . ', ';
- }
-
- if ($arrProvider['PROV_PAIS'] === 'MEX') {
- try {
- $arrEntity = (array) DB::table('S002V01TESTA')
- ->where('ESTA_NULI', '=', $line)
- ->where('ESTA_COES', '=', $arrProvider['PROV_ENTI'])
- ->where('ESTA_COPA', '=', $arrProvider['PROV_PAIS'])
- ->where('ESTA_ESTA', '=', 'Activo')
- ->first([ 'ESTA_COES', 'ESTA_NOES' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET016: Ocurrió un error al obtener la información de la entidad federativa.",
- $th->getMessage(),
- 500
- );
- }
- if ( empty($arrEntity) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET017: No se encontró la entidad federativa asociada al proveedor.",
- [],
- 500
- );
- }
- $address .= $arrEntity['ESTA_NOES'] . ', ';
- } else {
- $address .= $arrProvider['PROV_ENTI'] . ', ';
- }
- try {
- $arrCountry = (array) DB::table('S002V01TPAIS')
- ->where('PAIS_NULI', '=', $line)
- ->where('PAIS_IDPA', '=', $arrProvider['PROV_PAIS'])
- ->first([ 'PAIS_IDPA', 'PAIS_NOMB' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET018: Ocurrió un error al obtener la información del país.",
- $th->getMessage(),
- 500
- );
- }
- if ( empty($arrCountry) ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET019: No se encontró el país asociado al proveedor.",
- [],
- 500
- );
- }
- $address .= $arrCountry['PAIS_NOMB'] . '.';
- $html.='<div class="item">
- <b>Dirección: </b>
- <span>'.$address.'</span>
- </div>';
- if ( !empty($arrContact) ) {
- $html.='<div class="section-title">
- <b>Contactos</b>
- </div>';
- $html.='<table cellspacing="0" cellpadding="0">
- <thead>
- <tr>
- <th>ID</th>
- <th>Contacto</th>
- <th>Tipo de Contacto</th>
- <th>Correo Electrónico</th>
- <th>Teléfono</th>
- <th>Direcciones</th>
- <th>Observaciones</th>
- </tr>
- </thead>
- <tbody>';
- foreach ($arrContact as $keyContact => $contact) {
- $html.= '<tr>
- <td>'.$contact['PRCO_IDCP'].'</td>
- <td>'.$contact['PRCO_NOMB'].'</td>
- <td>'.$contact['PRCO_TIPO'].'</td>
- <td>'.$contact['PRCO_COR1'].'</td>
- <td>'.$contact['PRCO_LAD1'].' '.$contact['PRCO_TEL1'].'</td>
- <td>'.$contact['PRCO_CALL'].'</td>
- <td>'.$contact['PRCO_OBSE'].'</td>
- </tr>';
- }
- $html.= '</tbody>
- </table>';
- }
- if ( !empty($arrReference) ) {
- $html.='<div class="section-title">
- <b>Referencias</b>
- </div>';
- $html.='<table cellspacing="0" cellpadding="0">
- <thead>
- <tr>
- <th>ID</th>
- <th>Empresa</th>
- <th>R.F.C.</th>
- <th>Correo Electrónico</th>
- <th>Teléfono</th>
- <th>Dirección</th>
- </tr>
- </thead>
- <tbody>';
- foreach ($arrReference as $keyReference => $reference) {
- $html.= '<tr>
- <td>'.$reference['PRRE_IDRE'].'</td>
- <td>'.$reference['PRRE_EMPR'].'</td>
- <td>'.$reference['PRRE_XRFC'].'</td>
- <td>'.$reference['PRRE_CORR'].'</td>
- <td>'.$reference['PRRE_LADA'].' '.$reference['PRRE_TELE'].'</td>
- <td>'.$reference['PRRE_DIRE'].'</td>
- </tr>';
- }
- $html.= '</tbody>
- </table>';
- }
-
- if ( !empty($arrPayment) ) {
- $html.='<div class="section-title">
- <b>Métodos de Pago</b>
- </div>';
- $html.='<ol style="margin: 0;">';
- foreach ($arrPayment as $keyPayment => $payment) {
- $html.='<li>'.$payment.'</li>';
- }
- $html.='</ol>';
- }
- if ( !empty($arrCatalog) ) {
- $html.='<div class="section-title">
- <b>Catálogos</b>
- </div>';
- $html.='<table cellspacing="0" cellpadding="0">
- <thead>
- <tr>
- <th>ID</th>
- <th>Catálogo</th>
- <th>Descripción</th>
- <th>URL</th>
- </tr>
- </thead>
- <tbody>';
- foreach ($arrCatalog as $keyCatalog => $catalog) {
- $html.= '<tr>
- <td>'.$catalog['PRCE_IDCE'].'</td>
- <td>'.$catalog['PRCE_CATA'].'</td>
- <td>'.$catalog['PRCE_DESC'].'</td>
- <td>'.$catalog['PRCE_XURL'].'</td>
- </tr>';
- }
- $html.= '</tbody>
- </table>';
- }
- if ( !empty($arrCondition) ) {
- foreach ($arrCondition as $keyCondition => $condition) {
- $html.='<div class="section-title">
- <b>'.$condition['PRCN_TIPO'].'</b>
- </div>';
- $html.='<p>'.$condition['PRCN_INFO'].'</p>';
- }
- }
- $html.='</body></html>';
- $nuli = $this->resourcesController->formatSecuence($line, 2);
- $como = 'GEAD'; // Código del módulo
- $cldo = 'IN'; // Código de la clasificación
- $fecr = date('ymd'); // Fecha en la se carga el archivo
- try {
- $arrSecuence = (array) DB::table('S002V01TAFAL')
- ->where('AFAL_COMO', '=', $como)
- ->where('AFAL_CLDO', '=', $cldo)
- ->where('AFAL_NULI', '=', $line)
- ->orderBy('AFAL_NUSE', 'desc')
- ->first([ 'AFAL_NUSE' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET020: Ocurrió un error al obtener la información de la secuencia.",
- $th->getMessage(),
- 500
- );
- }
- $nuse = 1; // Secuencia del documento
- if ( !empty( $arrSecuence ) && !is_null( $arrSecuence ) ) {
- $nuse = intval( $arrSecuence['AFAL_NUSE'] ) + 1;
- }
- $nuse = $this->resourcesController->formatSecuence($nuse, 6);
- $nuve = $this->resourcesController->formatSecuence('1', 2);
- $noar = 'ficha_de_proveedor_' . $arrProvider['PROV_NUPR'];
- $nuli = $this->resourcesController->formatSecuence($line, 2);
- $como = 'GEAD'; // Código del módulo
- $cldo = 'IN'; // Código de la clasificación
- $fecr = date('ymd'); // Fecha en la se carga el archivo
- try {
- $arrSecuence = (array) DB::table('S002V01TAFAL')
- ->where('AFAL_COMO', '=', $como)
- ->where('AFAL_CLDO', '=', $cldo)
- ->where('AFAL_NULI', '=', $line)
- ->orderBy('AFAL_NUSE', 'desc')
- ->first([ 'AFAL_NUSE' ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET020: Ocurrió un error al obtener la información de la secuencia.",
- $th->getMessage(),
- 500
- );
- }
- $nuse = 1; // Secuencia del documento
- if ( !empty( $arrSecuence ) && !is_null( $arrSecuence ) ) {
- $nuse = intval( $arrSecuence['AFAL_NUSE'] ) + 1;
- }
- $nuse = $this->resourcesController->formatSecuence($nuse, 6);
- $nuve = $this->resourcesController->formatSecuence('1', 2);
- $noar = 'ficha_de_proveedor_' . $arrProvider['PROV_NUPR'];
- $exte = 'pdf';
-
- if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
- $filePath = 'C:/ITTEC/SAM/Dev/SistemaMantenimiento/sistema-mantenimiento-back/public/public_files/'; // API JEAN
- } else {
- $filePath = $this->functionsController->getApiURI().'public_files/'; // API QA
- }
- $fileName = $nuli.'-'.$como.'-'.$cldo.'-'.$fecr.'-'.$nuse.'='.$nuve.'='.$noar.'.'.$exte;
-
- $tempFile = $filePath . $fileName;
- $dompdf = new Dompdf();
- $dompdf ->loadHtml($html);
- $dompdf->setPaper('A4', 'portrait');
- $dompdf->render();
- $output = $dompdf->output();
- file_put_contents($tempFile, $output);
- $ubic = Storage::putFile('files', new File($tempFile));
- $ubic = str_replace("/", "\\", $ubic);
- $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
- $tama = filesize($ubic);
- $usac = json_encode([$user]);
- $now = $this->functionsController->now();
- $currentDate = $now->toDateTimeString();
- try {
- $validateInsert = DB::table('S002V01TAFAL')->insert([
- 'AFAL_NULI' => $line,
- 'AFAL_COMO' => $como,
- 'AFAL_CLDO' => $cldo,
- 'AFAL_FECR' => $fecr,
- 'AFAL_NUSE' => $nuse,
- 'AFAL_NUVE' => $nuve,
- 'AFAL_NOAR' => $noar,
- 'AFAL_EXTE' => $exte,
- 'AFAL_TAMA' => $tama,
- 'AFAL_UBIC' => $ubic,
- 'AFAL_USAC' => $usac,
- 'AFAL_USRE' => $user,
- 'AFAL_FERE' => $currentDate,
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET023: Ocurrió un error guardar los datos a la tabla final de archivos.",
- $th->getMessage(),
- 500
- );
- }
- if ( !$validateInsert ) {
- return $this->responseController->makeResponse(
- true,
- "ERR_PROVIDER_SHEET024: No se pudo guardar la ficha del proveedor en la base de datos.",
- [],
- 500
- );
- }
- $urlPublic = 'http://192.168.100.105:8000/public_files/' . $fileName;
- return $this->responseController->makeResponse(false, "EXITO: Modificación Exitosa", [ 'url' => $urlPublic ]);
- }
- }
|