| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200 |
- <?php
- /*
- Desarrollador: Ing. Jean Jairo Benitez Meza
- Ultima Modificación: 02/05/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\ResourcesController;
- use Illuminate\Http\Request;
- use Illuminate\Support\Carbon;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Validator;
- class ArtitleController extends Controller {
- private $responseController;
- private $encController;
- private $resourcesController;
- public function __construct() {
- $this->responseController = new ResponseController();
- $this->encController = new EncryptionController();
- $this->resourcesController = new ResourcesController();
- }
- // Función para obtener todas las familias
- public function getFamilies() {
- try {
- $arrFamilias = DB::table('S002V01TFAMI')
- ->get([
- 'FAMI_IDFA AS ID_FAMILIA',
- 'FAMI_NOMB AS FAMILIA',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFamilias);
- }
- // Función para obtener todas las familias activas
- public function getFamiliesActives() {
- try {
- $arrFamiliasActives = DB::table('S002V01TFAMI')
- ->where('FAMI_ESTA', '=', 'Activo')
- ->get([
- 'FAMI_IDFA AS ID_FAMILIA',
- 'FAMI_NOMB AS FAMILIA',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO", $arrFamiliasActives);
- }
- // Función para obtener las familias y las subfamilias activas
- public function getFamiliesAndSubfamilies ($line) {
- // Obtener las familias
- try {
- $arrFamilias = array();
- $arrFamilias = DB::table('S002V01TFAMI')
- ->where('FAMI_ESTA', '=', 'Activo')
- ->where('FAMI_NULI', '=', $line)
- ->get([
- 'FAMI_IDFA AS ID_FAMILIA',
- 'FAMI_NOMB AS FAMILIA',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET000: No se pudo realizar la consulta de las familias en la base.", [], 500);
- }
- // Obtener las subfamilias
- try {
- $arrSubfamilias = array();
- $arrSubfamilias = DB::table('S002V01TSUBF')
- ->where('SUBF_ESTA', '=', 'Activo')
- ->where('SUBF_NULI', '=', $line)
- ->get([
- 'SUBF_IDSU AS ID_SUBFAMILIA',
- 'SUBF_NOMB AS SUBFAMILIA',
- 'SUBF_IDFA AS ID_FAMILIA',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET001: No se pudo realizar la consulta de las subfamilias en la base.", [], 500);
- }
- try {
- $arrFamilasAndSubfamilias = array();
- foreach ($arrFamilias as $familias) {
- // Se genera el arreglo con las familias
- $arrFamilasTemp = array(
- "ID" => $familias->ID_FAMILIA,
- "NOMBRE" => $familias->FAMILIA,
- "SUBFAMILIAS" => array()
- );
- // Se iteran todas las subfamilias
- foreach ($arrSubfamilias as $subfamilias) {
- // Se asignan al arreglo temporal las subfamilias a las familias pertenecientes
- if ( $familias->ID_FAMILIA == $subfamilias->ID_FAMILIA ) {
- $arrFamilasTemp["SUBFAMILIAS"][] = array(
- "ID" => $subfamilias->ID_SUBFAMILIA,
- "NOMBRE" => $subfamilias->SUBFAMILIA,
- );
- }
- }
- // Se asigna al arreglo final
- $arrFamilasAndSubfamilias[] = $arrFamilasTemp;
- }
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET002: Ocurrió un error al generar la respuesta con las familias y subfamilias.", [], 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFamilasAndSubfamilias);
- }
- public function registerFamily(Request $request){
- $valitador = Validator::make($request->all(), [
- 'FAMILIA' => 'required|string|max:50',
- 'LINE' => 'required|integer',
- 'USER' => 'required|string'
- ]);
- if ($valitador->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_FAMILY_REG000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($valitador->errors()->messages()),
- 401
- );
- }
- DB::beginTransaction();
- $response = $request->all();
- try {
- $usuario = $this->encController->decrypt($response['USER']);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_FAMILY_REG001: Ocurrió un error al desencriptar los datos.", [], 401);
- }
- $currentDate = Carbon::now()->timezone('America/Mazatlan')->toDateTimeString();
- $arrInsert = [
- "FAMI_NOMB" => trim($response['FAMILIA']),
- "FAMI_USRE" => $usuario,
- "FAMI_NULI" => $response['LINE'],
- "FAMI_FERE" => $currentDate,
- "FAMI_FEAR" => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $valid = DB::table('S002V01TFAMI')->insert($arrInsert);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_FAMILY_REG002: Ocurrió un error al ingresar los registros.", [], 401);
- }
- if (!$valid) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_FAMILY_REG003: No se pudo ingresar los datos a la base de datos.", [], 401);
- }
- DB::commit();
- return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
- }
- public function getUnits($line) {
- try {
- $arrFamilias = DB::table('S002V01TUNID')
- ->where('UNID_NULI', '=', $line)
- ->get([
- 'UNID_IDUN AS ID_UNIDAD',
- 'UNID_NOMB AS UNIDAD',
- 'UNID_ESTA AS ESTADO',
- 'UNID_USRE AS USUARIO_REGISTRA',
- 'UNID_FERE AS FECHA_REGISTRA',
- 'UNID_USMO AS USUARIO_MODIFICA',
- 'UNID_FEMO AS FECHA_MODIFICA',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_UNIT_GET000: No se pudo realizar la consulta a la base.", [], 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO", $arrFamilias);
- }
- public function getUnitsActives($line) {
- try {
- $arrFamilias = DB::table('S002V01TUNID')
- ->where('UNID_NULI', '=', $line)
- ->where('UNID_ESTA', '=', 'Activo')
- ->get([
- 'UNID_IDUN AS ID_UNIDAD',
- 'UNID_NOMB AS UNIDAD',
- 'UNID_USRE AS USUARIO_REGISTRA',
- 'UNID_FERE AS FECHA_REGISTRA',
- 'UNID_USMO AS USUARIO_MODIFICA',
- 'UNID_FEMO AS FECHA_MODIFICA',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_UNIT_GET000: No se pudo realizar la consulta a la base.", [], 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFamilias);
- }
- public function registerUnit(Request $request){
- $valitador = Validator::make($request->all(), [
- 'UNIDAD' => 'required|string|max:50',
- 'LINE' => 'required|integer',
- 'USER' => 'required|string'
- ]);
- if ($valitador->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_UNIT_REG000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($valitador->errors()->messages()),
- 401
- );
- }
- DB::beginTransaction();
- $response = $request->all();
- try {
- $usuario = $this->encController->decrypt($response['USER']);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_UNIT_REG001: Ocurrió un error al desencriptar los datos.", [], 401);
- }
- $currentDate = Carbon::now()->timezone('America/Mazatlan')->toDateTimeString();
- $arrInsert = [
- "UNID_NOMB" => trim($response['UNIDAD']),
- "UNID_USRE" => $usuario,
- "UNID_NULI" => $response['LINE'],
- "UNID_FERE" => $currentDate,
- "UNID_FEAR" => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $valid = DB::table('S002V01TUNID')->insert($arrInsert);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_UNIT_REG002: Ocurrió un error al ingresar los registros.", [], 401);
- }
- if (!$valid) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_UNIT_REG003: No se pudo ingresar los datos a la base de datos.", [], 401);
- }
- DB::commit();
- return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
- }
- public function registerSubfamily(Request $request){
- $valitador = Validator::make($request->all(), [
- 'ID_FAMILIA' => 'required|integer',
- 'SUBFAMILIA' => 'required|string|max:50',
- 'LINE' => 'required|integer',
- 'USER' => 'required|string'
- ]);
- if ($valitador->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_SUBFAMILY_REG000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($valitador->errors()->messages()),
- 401
- );
- }
- DB::beginTransaction();
- $response = $request->all();
- try {
- $exist = DB::table('S002V01TFAMI')
- ->where('FAMI_IDFA', '=', trim($response['ID_FAMILIA']))
- ->where('FAMI_ESTA', '=', 'Activo')
- ->where('FAMI_NULI', '=', $response['LINE'])
- ->exists();
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_SUBFAMILY_REG002: Ocurrió al verificar la Familia.", [], 401);
- }
- if (!$exist) {
- return $this->responseController->makeResponse(true, "ERR_SUBFAMILY_REG003: La Familia seleccionada no existe.", [], 401);
- }
- try {
- $user = $this->encController->decrypt($response['USER']);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_SUBFAMILY_REG001: Ocurrió un error al desencriptar los datos.", [], 401);
- }
- $currentDate = Carbon::now()->timezone('America/Mazatlan')->toDateTimeString();
- $arrInsert = [
- "SUBF_IDFA" => $response['ID_FAMILIA'],
- "SUBF_NOMB" => $response['SUBFAMILIA'],
- "SUBF_USRE" => $user,
- "SUBF_NULI" => $response['LINE'],
- "SUBF_FERE" => $currentDate,
- "SUBF_FEAR" => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $valid = DB::table('S002V01TSUBF')->insert($arrInsert);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_SUBFAMILY_REG004: Ocurrió un error al ingresar los registros.", [], 401);
- }
- if (!$valid) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_SUBFAMILY_REG005: No se pudo ingresar los datos a la base de datos.", [], 401);
- }
- DB::commit();
- return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
- }
- public function getArtitles($line) {
- try {
- $resp = DB::table('S002V01TARTI')
- ->where("ARTI_NULI", "=", $line)
- ->where("ARTI_ESTA", "=", "Activo")
- ->join("S002V01TFAMI", "ARTI_IDFA", "=", "FAMI_IDFA")
- ->join("S002V01TSUBF", "ARTI_IDSU", "=", "SUBF_IDSU")
- ->join("S002V01TDEAR", "ARTI_IDAR", "=", "DEAR_IDAR")
- ->join("S002V01TPROV", "DEAR_NUPR", "=", "PROV_NUPR")
- ->join("S002V01TUNID", "DEAR_IDUN", "=", "UNID_IDUN")
- ->get([
- "DEAR_IDDE AS ID_DESC_ARTI",
- "ARTI_IDAR AS ID_ARTICULO",
- "ARTI_NOMB AS MODELO",
- "FAMI_IDFA AS ID_FAMILIA",
- "FAMI_NOMB AS FAMILIA",
- "SUBF_IDSU AS ID_SUBFAMILIA",
- "SUBF_NOMB AS SUBFAMILIA",
- "DEAR_DESC AS DESCRIPCION",
- "DEAR_CARA AS CARACTERISTICAS",
- "DEAR_COWE AS COMPRA_WEB",
- "DEAR_IDUN AS TIPO_UNIDAD",
- "DEAR_IMAG AS URL_IMAGEN",
- "PROV_NUPR AS ID_PROVEEDOR",
- "PROV_NOCO AS PROVEEDOR",
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $resp);
- }
- public function getArtitlesByProvider(Request $request) {
- $validator = Validator::make($request->all(), [
- 'lineNumber' => 'required|integer',
- 'idArtitle' => 'required|string',
- 'idProvider' => 'required|string'
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLE_GET000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- $dataRequest = $request->all();
- $idArtitle = $this->encController->decrypt( $dataRequest['idArtitle'] );
- $idProvider = $this->encController->decrypt( $dataRequest['idProvider'] );
- try {
- $objArtitle = DB::table('S002V01TARTI')
- ->where("ARTI_NULI", "=", $dataRequest['lineNumber'])
- // ->where("DEAR_IDAR", "=", $idArtitle)
- ->where("DEAR_NUPR", "=", $idProvider)
- ->join("S002V01TFAMI", "ARTI_IDFA", "=", "FAMI_IDFA")
- ->join("S002V01TSUBF", "ARTI_IDSU", "=", "SUBF_IDSU")
- ->join("S002V01TDEAR", "ARTI_IDAR", "=", "DEAR_IDAR")
- ->join("S002V01TPROV", "DEAR_NUPR", "=", "PROV_NUPR")
- ->join("S002V01TUNID", "DEAR_IDUN", "=", "UNID_IDUN")
- ->first([
- "DEAR_IDDE AS ID_DESC_ARTI",
- "ARTI_IDAR AS ID_ARTICULO",
- // "ARTI_CODI AS CODIGO",
- "ARTI_NOMB AS MODELO",
- "FAMI_IDFA AS ID_FAMILIA",
- "FAMI_NOMB AS FAMILIA",
- "SUBF_IDSU AS ID_SUBFAMILIA",
- "SUBF_NOMB AS SUBFAMILIA",
- "DEAR_DESC AS DESCRIPCION",
- "DEAR_CARA AS CARACTERISTICAS",
- "DEAR_COWE AS COMPRA_WEB",
- "UNID_IDUN AS ID_UNIDAD",
- "UNID_NOMB AS UNIDAD",
- // "DEAR_INPR AS INFO_PRODUCTO",
- "DEAR_IMAG AS URL_IMAGEN",
- "PROV_NUPR AS ID_PROVEEDOR",
- "PROV_NOCO AS PROVEEDOR",
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET001: No se pudo realizar la consulta a la base.", [], 500);
- }
- if ( empty($objArtitle) ) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET002: No se encontró el resultado deseado.", [], 500);
- }
- try {
- $arrInformation = DB::table('S002V01TINAR')
- ->where('INAR_ESTA', '=', 'Activo')
- ->where('INAR_NULI', '=', $dataRequest['lineNumber'])
- ->where('INAR_IDDE', '=', $objArtitle->ID_DESC_ARTI)
- ->get([
- 'INAR_IDIN AS NUMERO_INFORMACION',
- 'INAR_CODI AS CODIGO',
- 'INAR_MODE AS MODELO',
- 'INAR_MONE AS MONEDA',
- 'INAR_PREC AS PRECIO',
- 'INAR_CANT AS CANTIDAD',
- 'INAR_CARA AS CARACTERISTICAS',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET003: No se pudo realizar la consulta a la base.", [], 500);
- }
- $objArtitle->INFO_PRODUCTO = json_encode($arrInformation);
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $objArtitle);
- }
- public function getArtitleById(Request $request) {
- $validator = Validator::make($request->all(), [
- 'lineNumber' => 'required|integer',
- 'idArtitle' => 'required|string',
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLE_GET000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- $request = $request->all();
- $idArtitle = $this->encController->decrypt($request['idArtitle']);
- try {
- $arrArtitle = DB::table('S002V01TARTI')
- ->where('ARTI_IDAR', '=', $idArtitle)
- ->where('ARTI_ESTA', '=', 'Activo')
- ->where('ARTI_NULI', '=', $request['lineNumber'])
- ->join("S002V01TFAMI", "ARTI_IDFA", "=", "FAMI_IDFA")
- ->join("S002V01TSUBF", "ARTI_IDSU", "=", "SUBF_IDSU")
- ->first([
- 'ARTI_IDAR AS NUMERO_ARTICULO',
- 'ARTI_CODI AS CODIGO',
- "FAMI_IDFA AS ID_FAMILIA",
- "FAMI_NOMB AS FAMILIA",
- "SUBF_IDSU AS ID_SUBFAMILIA",
- "SUBF_NOMB AS SUBFAMILIA",
- 'ARTI_NOMB AS ARTICULO',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET001: No se pudo realizar la consulta a la base.", [], 500);
- }
- try {
- $arrDescription = DB::table('S002V01TDEAR')
- ->where('DEAR_IDAR', '=', $idArtitle)
- ->where('DEAR_ESTA', '=', 'Activo')
- ->where('DEAR_NULI', '=', $request['lineNumber'])
- ->join("S002V01TUNID", "DEAR_IDUN", "=", "UNID_IDUN")
- ->get([
- 'DEAR_IDDE AS ID_DESCRIPCION',
- 'DEAR_DESC AS DESCRIPCION',
- 'DEAR_CARA AS CARACTERISTICAS',
- 'DEAR_COWE AS COMPRA_WEB',
- 'DEAR_IDUN AS TIPO_UNIDAD',
- 'DEAR_IMAG AS IMAGEN',
- 'DEAR_NUPR AS PROVEEDOR',
- 'DEAR_NUPR AS PROVEEDOR',
- 'DEAR_ESTA AS ESTADO',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET002: No se pudo realizar la consulta a la base.", [], 500);
- }
- if ( empty($arrDescription) ) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET003: No se encontró ninguna descripción.", [], 500);
- }
- foreach ($arrDescription as $description) {
- try {
- $arrDetails = DB::table('S002V01TINAR')
- ->where('INAR_IDDE', '=', $description->ID_DESCRIPCION)
- ->where('INAR_ESTA', '=', 'Activo')
- ->where('INAR_NULI', '=', $request['lineNumber'])
- ->get([
- 'INAR_IDIN AS NUMERO_DETALLE',
- 'INAR_CODI AS CODIGO',
- 'INAR_MODE AS MODELO',
- 'INAR_MONE AS MONEDA',
- 'INAR_PREC AS PRECIO',
- 'INAR_CANT AS CANTIDAD',
- 'INAR_CARA AS CARACTERISTICAS',
- 'INAR_ESTA AS ESTADO',
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET004: No se pudo realizar la consulta a la base.", [], 500);
- }
- $description->DETALLES = $arrDetails;
- try {
- $objProdiver = DB::table('S002V01TPROV')
- ->where('PROV_NUPR', '=', $description->PROVEEDOR)
- ->where('PROV_ESTA', '=', 'Activo')
- ->where('PROV_NULI', '=', $request['lineNumber'])
- ->first([
- '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_GIRO AS GIRO_EMPRESA',
- 'PROV_TIPO AS TIPO_EMPRESA',
- 'PROV_SIWE AS SITIO_WEB',
- 'PROV_MEPA AS METODO_PAGO',
- 'PROV_USRE AS USUARIO_REGISTRA',
- 'PROV_FERE AS FECHA_REGISTRA',
- 'PROV_USMO AS USUARIO_MODIFICA',
- 'PROV_FEMO AS FECHA_MODIFICA',
- ]);
- $description->PROVEEDOR = $objProdiver;
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET005: No se pudo realizar la consulta a la base.", [], 500);
- }
- }
- $arrArtitle->INFORMACION = $arrDescription;
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrArtitle);
- }
- public function getAllArtitles($line) {
- try {
- $resp = DB::table('S002V01TARTI')
- ->where("ARTI_NULI", "=", $line)
- ->join("S002V01TFAMI", "ARTI_IDFA", "=", "FAMI_IDFA")
- ->join("S002V01TSUBF", "ARTI_IDSU", "=", "SUBF_IDSU")
- ->get([
- "ARTI_IDAR AS ID_ARTICULO",
- "ARTI_NOMB AS MODELO",
- "FAMI_IDFA AS ID_FAMILIA",
- "FAMI_NOMB AS FAMILIA",
- "SUBF_IDSU AS ID_SUBFAMILIA",
- "SUBF_NOMB AS SUBFAMILIA",
- "ARTI_ESTA AS ESTADO",
- "ARTI_USRE AS USUARIO_REGISTRA",
- "ARTI_FERE AS FECHA_REGISTRA",
- "ARTI_USMO AS USUARIO_MODIFICA",
- "ARTI_FEMO AS FECHA_MODIFICA",
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET000: No se pudo realizar la consulta a la base.", [], 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $resp);
- }
- public function registerArtitles(Request $request) {
- $validator = Validator::make($request->all(), [
- 'CODIGO' => 'required|string',
- 'ARTICULO' => 'required|string',
- 'FAMILIA' => 'required|integer',
- 'SUBFAMILIA' => 'required|integer',
- 'INFORMATION' => 'required',
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_TABLE_REG000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- DB::beginTransaction();
- $response = $request->all();
- try {
- $usuario = $this->encController->decrypt($response['USUARIO']);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG000: No se pudo obtener los datos del usuario", [], 500);
- }
- $currentDate = Carbon::now()->timezone('America/Mazatlan')->toDateTimeString();
- $insertArtitle = [
- 'ARTI_CODI' => $response['CODIGO'],
- 'ARTI_IDFA' => $response['FAMILIA'],
- 'ARTI_IDSU' => $response['SUBFAMILIA'],
- 'ARTI_NOMB' => $response['ARTICULO'],
- 'ARTI_NULI' => $response['NUMERO_LINEA'],
- 'ARTI_USRE' => $usuario,
- 'ARTI_FERE' => $currentDate,
- 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $idArtitle = DB::table('S002V01TARTI')->insertGetId($insertArtitle);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG001: No se pudo realizar la consulta a la base.", [], 500);
- }
- $arrInformation = $response['INFORMATION'];
- foreach ($arrInformation as $key => $information) {
- $ruta = storage_path().'/app/public/GEAD/';
- $cont = -2;
- if (is_dir($ruta)){
- $gestor = opendir($ruta);
- while (($archivo = readdir($gestor)) !== false) {
- $cont++;
- }
- }
- $numeroLinea = $this->resourcesController->formatSecuence($response['NUMERO_LINEA'],2);
- $numeroSecuencia = $this->resourcesController->formatSecuence($cont,6);
- $image = $information['URLIMAGE'];
- $image = str_replace('data:image/jpeg;base64,', '', $image);
- $image = str_replace(' ', '+', $image);
- $date = date("ymd");
- $nameArtitle = strtoupper(str_replace(' ', '_', $response['ARTICULO']));
- $imageName = $numeroLinea.'-GEAD-FO-'.$date.'-'.$numeroSecuencia.'-01-'.$nameArtitle.'.jpeg';
- try {
- \File::put(storage_path(). '/app/public/GEAD/' . $imageName, base64_decode($image));
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG002: Ocurrió un error al guardar la imagen en la base de datos documental.", [], 500);
- }
- $insertInformation = [
- 'DEAR_DESC' => $information['DESCRIPCION'],
- 'DEAR_CARA' => $information['CARACTERISTICAS'],
- 'DEAR_COWE' => $information['COMPRA_WEB'],
- 'DEAR_IDUN' => $information['TIPO_UNIDAD'],
- 'DEAR_IMAG' => $imageName,
- 'DEAR_NUPR' => $information['PROVEEDOR'],
- 'DEAR_IDAR' => $idArtitle,
- 'DEAR_NULI' => $response['NUMERO_LINEA'],
- 'DEAR_USRE' => $usuario,
- 'DEAR_FERE' => $currentDate,
- 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $idDescription = DB::table('S002V01TDEAR')->insertGetId($insertInformation);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG003: Ocurrió un error al insertar los datos de la información del artículo.", $th->getMessage(), 500);
- }
- $arrDetails = $information['DETAILS'];
- foreach ($arrDetails as $keyDetails => $details) {
- $insertDetails = [
- 'INAR_IDDE' => $idDescription,
- 'INAR_CODI' => $details['CODIGO'],
- 'INAR_MODE' => $details['MODELO'],
- 'INAR_MONE' => $details['MONEDA'],
- 'INAR_PREC' => $details['PRECIO'],
- 'INAR_CANT' => $details['CANTIDAD'],
- 'INAR_CARA' => $details['CARACTERISTICAS'],
- 'INAR_NULI' => $response['NUMERO_LINEA'],
- 'INAR_USRE' => $usuario,
- 'INAR_FERE' => $currentDate,
- 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $idDetails = DB::table('S002V01TINAR')->insertGetId($insertDetails);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_REG003: Ocurrió un error al insertar los datos de los detalles del artículo.", [], 500);
- }
- }
- }
- DB::commit();
- return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
- }
- public function updateArtitles(Request $request) {
- $validator = Validator::make($request->all(), [
- 'NO' => 'required|string',
- 'CODIGO' => 'required|string',
- 'ARTICULO' => 'required|string',
- 'FAMILIA' => 'required|integer',
- 'SUBFAMILIA' => 'required|integer',
- 'INFORMATION' => 'required',
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLE_MOD000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- DB::beginTransaction(); # Para impedir que las actualizaciones queden a incompletas
- $response = $request->all();
- $usuario = $this->encController->decrypt($response['USUARIO']);
- $currentDate = Carbon::now()->timezone('America/Mazatlan')->toDateTimeString();
- $numeroArticulo = $response['NO'];
- $update = [
- 'ARTI_CODI' => $response['CODIGO'],
- 'ARTI_IDFA' => $response['FAMILIA'],
- 'ARTI_IDSU' => $response['SUBFAMILIA'],
- 'ARTI_NOMB' => $response['ARTICULO'],
- 'ARTI_USMO' => $usuario,
- 'ARTI_FEMO' => $currentDate,
- 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
- ];
- try {
- $resp = DB::table('S002V01TARTI')->where('ARTI_IDAR', '=', $numeroArticulo)->update($update);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD002: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD001: Ocurrió un error al modificar el registro.", [], 500);
- }
- $arrInformation = $response['INFORMATION'];
- foreach ($arrInformation as $keyInformation => $information) {
- // Número de ID de información
- $numeroInformation = $information['NO'];
- // Se verifica si la información ya está registrado o no
- if ( $information['ESTADO'] === 'Modificado' || $information['ESTADO'] === 'Activo' ) {
- // Si la información cuenta con más de 1000 caracteres, entonces es una imágen nueva
- if ( strlen($information['URLIMAGE']) > 1000 ) {
- $ruta = storage_path().'/app/public/GEAD/';
- $cont = -2;
- if (is_dir($ruta)){
- $gestor = opendir($ruta);
- while (($archivo = readdir($gestor)) !== false) {
- $cont++;
- }
- } else {
- // Método Recursivo para generar la ruta del archivo
- $arrResponseCreate = $this->createRouteSave('app/public/GEAD');
- if ($arrResponseCreate['error']) {
- return $this->responseController->makeResponse(true, $arrResponseCreate['msg'], $arrResponseCreate['response'], 500);
- }
- }
- $numeroLinea = $this->resourcesController->formatSecuence($response['NUMERO_LINEA'],2);
- $numeroSecuencia = $this->resourcesController->formatSecuence($cont,6);
- $image = $information['URLIMAGE'];
- $image = str_replace('data:image/jpeg;base64,', '', $image);
- $image = str_replace(' ', '+', $image);
- $date = date("ymd");
- $nameArtitle = strtoupper(str_replace(' ', '_', $response['ARTICULO']));
- $imageName = $numeroLinea.'-GEAD-FO-'.$date.'-'.$numeroSecuencia.'-01-'.$nameArtitle.'.jpeg';
- try {
- \File::put(storage_path(). '\\app\\public\\GEAD\\' . $imageName, base64_decode($image));
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD003: No se pudo registrar la imagen en la base de datos documental.", $th->getMessage(), 500);
- }
- } else {
- $imageName = $information['URLIMAGE'];
- }
- $update = [
- 'DEAR_DESC' => $information['DESCRIPCION'],
- 'DEAR_CARA' => $information['CARACTERISTICAS'],
- 'DEAR_COWE' => $information['COMPRA_WEB'],
- 'DEAR_IDUN' => $information['TIPO_UNIDAD'],
- 'DEAR_IMAG' => $imageName,
- 'DEAR_NUPR' => $information['PROVEEDOR'],
- // 'DEAR_ESTA' => $information['ESTADO'],
- 'DEAR_USMO' => $usuario,
- 'DEAR_FEMO' => $currentDate,
- 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
- ];
- try {
- $resp = DB::table('S002V01TDEAR')->where('DEAR_IDDE', '=', $numeroInformation)->update($update);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD005: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD004: Ocurrió un error al obtener el contenido.", [], 500);
- }
- $arrDetails = $information['DETAILS'];
- foreach ($arrDetails as $keyDetails => $details) {
- $numeroDetails = $details['NO'];
- if ( $details['ESTADO'] === 'Modificado' || $details['ESTADO'] === 'Activo') {
- $update = [
- 'INAR_CODI' => $details['CODIGO'],
- 'INAR_MODE' => $details['MODELO'],
- 'INAR_MONE' => $details['MONEDA'],
- 'INAR_PREC' => $details['PRECIO'],
- 'INAR_CANT' => $details['CANTIDAD'],
- 'INAR_CARA' => $details['CARACTERISTICAS'],
- 'INAR_USMO' => $usuario,
- 'INAR_FEMO' => $currentDate,
- 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
- ];
- try {
- $resp = DB::table('S002V01TINAR')->where('INAR_IDIN', '=', $numeroDetails)->update($update);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD007: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD006: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } else if ($details['ESTADO'] === 'Nuevo') {
- $insertDetails = [
- 'INAR_IDDE' => $numeroInformation,
- 'INAR_CODI' => $details['CODIGO'],
- 'INAR_MODE' => $details['MODELO'],
- 'INAR_MONE' => $details['MONEDA'],
- 'INAR_PREC' => $details['PRECIO'],
- 'INAR_CANT' => $details['CANTIDAD'],
- 'INAR_CARA' => $details['CARACTERISTICAS'],
- 'INAR_NULI' => $response['NUMERO_LINEA'],
- 'INAR_USRE' => $usuario,
- 'INAR_FERE' => $currentDate,
- 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $resp = DB::table('S002V01TINAR')->insertGetId($insertDetails);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD009: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD008: Ocurrió un error al obtener el contenido.", [], 500);
- }
- } else if ($details['ESTADO'] === 'Eliminado') {
- $update = [
- 'INAR_ESTA' => 'Eliminado',
- 'INAR_USMO' => $usuario,
- 'INAR_FEMO' => $currentDate,
- 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
- ];
- try {
- $resp = DB::table('S002V01TINAR')->where('INAR_IDIN', '=', $numeroDetails)->update($update);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD011: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD010: Ocurrió un error al obtener el contenido.", [], 500);
- }
- }
- }
- } else if ($information['ESTADO'] === 'Nuevo') {
- $ruta = storage_path().'/app/public/GEAD/';
- $cont = -2;
- if (is_dir($ruta)){
- $gestor = opendir($ruta);
- while (($archivo = readdir($gestor)) !== false) {
- $cont++;
- }
- }
- $numeroLinea = $this->resourcesController->formatSecuence($response['NUMERO_LINEA'],2);
- $numeroSecuencia = $this->resourcesController->formatSecuence($cont,6);
- $image = $information['URLIMAGE'];
- $image = str_replace('data:image/jpeg;base64,', '', $image);
- $image = str_replace(' ', '+', $image);
- $date = date("ymd");
- $nameArtitle = strtoupper(str_replace(' ', '_', $response['ARTICULO']));
- $imageName = $numeroLinea.'-GEAD-FO-'.$date.'-'.$numeroSecuencia.'-01-'.$nameArtitle.'.jpeg';
- try {
- \File::put(storage_path(). '/app/public/GEAD/' . $imageName, base64_decode($image));
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD012: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- $insertInformation = [
- 'DEAR_DESC' => $information['DESCRIPCION'],
- 'DEAR_CARA' => $information['CARACTERISTICAS'],
- 'DEAR_COWE' => $information['COMPRA_WEB'],
- 'DEAR_IDUN' => $information['TIPO_UNIDAD'],
- 'DEAR_IMAG' => $imageName,
- 'DEAR_NUPR' => $information['PROVEEDOR'],
- 'DEAR_IDAR' => $numeroArticulo,
- 'DEAR_NULI' => $response['NUMERO_LINEA'],
- 'DEAR_USRE' => $usuario,
- 'DEAR_FERE' => $currentDate,
- 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- $numeroInformation = DB::table('S002V01TDEAR')->insertGetId($insertInformation);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD013: Ocurrió un error al insertar los datos de la información del artículo.", [], 500);
- }
- $arrDetails = $information['DETAILS'];
- foreach ($arrDetails as $keyDetails => $details) {
- $insertDetails = [
- 'INAR_IDDE' => $numeroInformation,
- 'INAR_CODI' => $details['CODIGO'],
- 'INAR_MODE' => $details['MODELO'],
- 'INAR_MONE' => $details['MONEDA'],
- 'INAR_PREC' => $details['PRECIO'],
- 'INAR_CANT' => $details['CANTIDAD'],
- 'INAR_CARA' => $details['CARACTERISTICAS'],
- 'INAR_NULI' => $response['NUMERO_LINEA'],
- 'INAR_USRE' => $usuario,
- 'INAR_FERE' => $currentDate,
- 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP')
- ];
- try {
- DB::table('S002V01TINAR')->insertGetId($insertDetails);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD014: Ocurrió un error al insertar los datos de los detalles del artículo.", [], 500);
- }
- }
- } else if ($information['ESTADO'] === 'Eliminado') {
- $update = [
- 'DEAR_ESTA' => 'Eliminado',
- 'DEAR_USMO' => $usuario,
- 'DEAR_FEMO' => $currentDate,
- 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
- ];
- try {
- $resp = DB::table('S002V01TDEAR')->where('DEAR_IDDE', '=', $numeroInformation)->update($update);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD016: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_MOD015: Ocurrió un error al obtener el contenido.", [], 500);
- }
- }
- }
- DB::commit(); # Para guardar los cambios en la base de datos
- return $this->responseController->makeResponse(false, "ÉXITO: Modificación Exitosa");
- }
- public function deleteArtitle(Request $request) {
- $validator = Validator::make($request->all(), [
- 'NUMERO_ARTITULO' => 'required|string',
- 'NUMERO_LINEA' => 'required|string',
- 'USUARIO' => 'required|string',
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLE_MOD000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- $response = $request->all();
- $numeroLinea = $response['NUMERO_LINEA'];
- $numeroArticulo = $this->encController->decrypt($response['NUMERO_ARTITULO']);
- $usuario = $this->encController->decrypt($response['USUARIO']);
- DB::beginTransaction();
- $currentDate = Carbon::now()->timezone('America/Mazatlan')->toDateTimeString();
- $update = [
- 'ARTI_ESTA' => 'Eliminado',
- 'ARTI_USMO' => $usuario,
- 'ARTI_FEMO' => $currentDate,
- 'ARTI_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
- ];
- try {
- $resp = DB::table('S002V01TARTI')
- ->where('ARTI_IDAR', '=', $numeroArticulo)
- ->where('ARTI_NULI', '=', $numeroLinea)
- ->update($update);
- if (!$resp) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL001: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL002: Ocurrió un error al modificar el registro.", [], 500);
- }
- try {
- $arrDescription = DB::table('S002V01TDEAR')->where('DEAR_IDAR', '=', $numeroArticulo)->get([ 'DEAR_IDDE AS NUMERO_DESCRIPCION' ]);
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL003: Ocurrió un error al obtener los datos de la descripción del artículo", [], 500);
- }
- foreach ($arrDescription as $keyDescription => $description) {
- $numeroDescripcion = $description->NUMERO_DESCRIPCION;
- $update = [
- 'DEAR_ESTA' => 'Eliminado',
- 'DEAR_USMO' => $usuario,
- 'DEAR_FEMO' => $currentDate,
- 'DEAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
- ];
- try {
- $resp = DB::table('S002V01TDEAR')->where('DEAR_IDDE', '=', $numeroDescripcion)->where('DEAR_NULI', '=', $numeroLinea)->update($update);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL004: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL005: Ocurrió un error al modificar el registro.", [], 500);
- }
- $update = [
- 'INAR_ESTA' => 'Eliminado',
- 'INAR_USMO' => $usuario,
- 'INAR_FEMO' => $currentDate,
- 'INAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
- ];
- try {
- $resp = DB::table('S002V01TINAR')->where('INAR_IDDE', '=', $numeroDescripcion)->where('INAR_NULI', '=', $numeroLinea)->update($update);
- if (!$resp) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL006: Ocurrió un error al modificar en la tabla.", [], 500);
- }
- } catch (\Throwable $th) {
- DB::rollBack();
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_DEL007: Ocurrió un error al modificar el registro.", [], 500);
- }
- }
- DB::commit(); # Para guardar los cambios en la base de datos
- return $this->responseController->makeResponse(false, "ÉXITO: Eliminación Exitosa");
- }
- public function generateArtitles(Request $request) {
- $validator = Validator::make($request->all(), [
- 'FILE_ZIP' => 'required',
- 'NUMERO_LINEA' => 'required',
- 'USUARIO' => 'required',
- ]);
- if ($validator->fails()) {
- return $this->responseController->makeResponse(
- true,
- "ERR_ARTITLE_MOD000: Se encontraron uno o más errores.",
- $this->responseController->makeErrors($validator->errors()->messages()),
- 401
- );
- }
- }
- public function getArtitleByInformation($information, $line) {
- try {
- $objInformation = DB::table('S002V01TINAR')
- ->where('INAR_IDIN', '=', $information)
- ->where('INAR_ESTA', '=', 'Activo')
- ->where('DEAR_ESTA', '=', 'Activo')
- ->where('ARTI_ESTA', '=', 'Activo')
- ->where('FAMI_ESTA', '=', 'Activo')
- ->where('SUBF_ESTA', '=', 'Activo')
- ->where('UNID_ESTA', '=', 'Activo')
- ->where('PROV_ESTA', '=', 'Activo')
- ->join('S002V01TDEAR', 'DEAR_IDDE', '=', 'INAR_IDDE')
- ->join('S002V01TARTI', 'ARTI_IDAR', '=', 'DEAR_IDAR')
- ->join('S002V01TFAMI', 'FAMI_IDFA', '=', 'ARTI_IDFA')
- ->join('S002V01TSUBF', 'SUBF_IDSU', '=', 'ARTI_IDSU')
- ->join('S002V01TUNID', 'UNID_IDUN', '=', 'DEAR_IDUN')
- ->join('S002V01TPROV', 'PROV_NUPR', '=', 'DEAR_NUPR')
- ->first([
- 'INAR_IDIN', // Identificador de Información del artículo
- 'INAR_CODI', // Código del artículo
- 'INAR_MODE', // Modelo del artículo
- 'INAR_MONE', // Moneda
- 'INAR_PREC', // Precio
- 'INAR_CANT', // Cantidad
- 'INAR_CARA', // Características
- 'DEAR_IDDE', // Identificador de la descripción del artículo
- 'DEAR_DESC', // Descripción del artículo
- 'DEAR_CARA', // Características del artículo
- 'DEAR_COWE', // Compra web
- 'DEAR_TIPO', // Tipo
- 'DEAR_IMAG', // Imagen
- 'DEAR_IDUN', // Identificador de la unidad
- 'UNID_NOMB', // Nombre de la unidad
- 'UNID_ACRO', // Acrónimo de la familia
- 'DEAR_NUPR', // Número del proveedor
- 'ARTI_IDAR', // Identificador del artículo
- 'ARTI_IDFA', // Identificador de la familia
- 'FAMI_NOMB', // Nombre de la familia
- 'ARTI_IDSU', // Identificador de la subfamilia
- 'SUBF_NOMB', // Nombre de la subfamilia
- 'ARTI_CODI', // Código del artículo
- 'ARTI_NOMB', // Nombre del artículo
- 'PROV_NOCO', // Nombre comercial
- 'PROV_NOMB', // Nombre del proveedor
- 'PROV_APPA', // Apellido paterno del proveedor
- 'PROV_APMA', // Apellido materno del proveedor
- 'PROV_CORR', // Correo electrónico
- 'PROV_LAD1', // Lada 1
- 'PROV_TEL1', // Teléfono 1
- 'PROV_LAD2', // Lada 2
- 'PROV_TEL2', // Teléfono 2
- 'PROV_XRFC', // R.F.C
- 'PROV_XTAX', // TAX ID
- 'PROV_GIRO', // Giro empresarial
- 'PROV_TIPO', // Tipo
- 'PROV_SIWE', // Sitio Web
- 'PROV_MEPA', // Metodos de pago
- ]);
- } catch (\Throwable $th) {
- return $this->responseController->makeResponse(true, "ERR_ARTITLE_GET000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
- }
- return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $objInformation);
- }
- private $index = 0;
- private function createRouteSave ($path, $savePath = '') {
- try {
- $arrPath = explode('/',$path);
- $maxPath = count($arrPath);
- if ( is_dir( storage_path() . '/' . $savePath . $arrPath[$this->index] ) && $maxPath > $this->index){
- $savePath .= $arrPath[$this->index] . '/';
- $this->index += 1;
- if ($maxPath > $this->index) {
- $this->createRouteSave($path, $savePath);
- }
- } else if ( ! is_dir( storage_path() . '/' . $savePath . $arrPath[$this->index] ) ) {
- try {
- if ( ! mkdir( storage_path() . '/' . $savePath . $arrPath[$this->index] ) ) {
- return [
- "error" => true,
- "msg" => "ERR_PATH_CRE000: Ocurrió un error al crear la carpeta " . $arrPath[$this->index],
- "response" => storage_path() . '/' . $savePath . $arrPath[$this->index]
- ];
- }else{
- $this->createRouteSave($path, $savePath);
- }
- } catch (\Throwable $th) {
- return [
- "error" => true,
- "msg" => "ERR_PATH_CRE001: Ocurrió un error inesperado al crear la ruta del archivo",
- "response" => $th->getMessage()
- ];
- }
- }
- $this->index = 0;
- return [
- "error" => false,
- "msg" => "Creación de Ruta Exitosa",
- "response" => storage_path() . '/' . $savePath . $arrPath[$this->index]
- ];
- } catch (\Throwable $th) {
- return [
- "error" => true,
- "msg" => "ERR_PATH_CRE002: Ocurrió un error inesperado al generar la ruta del archivo",
- "response" => $th->getMessage()
- ];
- }
- }
- }
|