瀏覽代碼

Modificación de controladores de inventario

JeanBenitez 2 年之前
父節點
當前提交
a8d04bf3de

+ 245 - 171
sistema-mantenimiento-back/app/Http/Controllers/DocumentManagementController.php

@@ -13,11 +13,13 @@ class DocumentManagementController extends Controller{
   private $responseController;
   private $encryptionController;
   private $functionsController;
+  private $resourcesController;
 
   public function __construct(){
       $this->responseController = new ResponseController();
       $this->encryptionController = new EncryptionController();
       $this->functionsController = new FunctionsController();
+      $this->resourcesController = new ResourcesController();
   }
 
   public function downloadFile($token, $idUser, $line){
@@ -691,180 +693,252 @@ class DocumentManagementController extends Controller{
       return $this->responseController->makeresponse(false, "EXITO");
   }
 
-  public function moveFinalFile(int $line, string $como, string $cldo, object $tempFile, string $idUser) {
-      $modulesCodes = [
-          "GEAD","GIST","GMPR","GMCO","GEEQ","COAC","GEPR",
-          "ANFA","PCSA","GPRS","GEPR","GDEL","ADSI","USPE"
-      ];
-
-      $clasifications = [
-          "AV","AU","CA","CE","CO","DP","FA","FI",
-          "FO","IN","LA","OR","PL","RE","VI"
-      ];
-
-      if(!in_array($como, $modulesCodes)){
-          return [false, "El código $como es inválido."];
-      }
-
-      if(!in_array($cldo, $clasifications)){
-          return [false, "La clasificación $cldo es inválida."];
-      }
-
-      $now = $this->functionsController->now();
-      $nowStr = $now->toDateTimeString();
-      $dateTimeArr = explode(' ', $nowStr);
-      $dateArr = explode('-', $dateTimeArr[0]);
-      $year = substr($dateArr[0], 2);
-
-      $fecr = "$year$dateArr[1]$dateArr[2]";
-      $sec = DB::table('S002V01TAFAL')->where([
-          ['AFAL_COMO', '=', $como],
-          ['AFAL_CLDO', '=', $cldo],
-          ['AFAL_NULI', '=', $line],
-      ])->orderBy('AFAL_NUSE', 'desc')->first();
-
-      $nuse = 1;
-      if(!is_null($sec)){
-          $nuse = intval($sec->AFAL_NUSE) + 1;
-      }
-
-      $fileNameArr = explode('.', $tempFile->ARTE_NOAR);
-      array_pop($fileNameArr);
-
-      $noar = implode('.', $fileNameArr);
-      $exte = $tempFile->ARTE_EXTE;
-
-      $ver = DB::table('S002V01TAFAL')->where([
-          ['AFAL_NULI', '=', $line],
-          ['AFAL_COMO', '=', $como],
-          ['AFAL_CLDO', '=', $cldo],
-          ['AFAL_NOAR', '=', $noar],
-          ['AFAL_EXTE', '=', $exte],
-      ])->orderBy('AFAL_NUVE', 'desc')->first();
-
-      $nuve = 1;
-      if(!is_null($ver)){
-          $nuve = intval($sec->AFAL_NUVE) + 1;
-      }
-
-      $tama = $tempFile->ARTE_TAMA;
-      $ubiFileArr = explode('tempFiles', $tempFile->ARTE_UBTE);
-      $ubic = $ubiFileArr[0] . 'files' . $ubiFileArr[1];
-
-      if(file_exists($tempFile->ARTE_UBTE)){
-          rename($tempFile->ARTE_UBTE, $ubic);
-          DB::table('S002V01TARTE')->where([
-              ['ARTE_IDAR', '=', $tempFile->ARTE_IDAR],
-              ['ARTE_NULI', '=', $line],
-          ])->update([
-              'ARTE_ESTA' => 'Eliminado',
-              'ARTE_USMO' => $idUser,
-              'ARTE_FEMO' => $nowStr,
-          ]);
-      }
-
-      $code = $line < 10 ? "0$line" : "$line";
-      $code .= "-$como-$cldo-$fecr-";
-
-      for($i = strlen($nuse); $i < 6; $i++){
-          $code .= "0";
-      }
-
-      $code .= "$nuse=";
-      $code .= $nuve < 10 ? "0$nuve=" : "$nuve=";
-      $code .= "$noar.$exte";
-
-      $usac = json_encode([$idUser]);
-
-      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' => $idUser,
-          'AFAL_FERE' => $nowStr
-      ]);
-
-      return [true, $code];
-  }
+    public function moveFinalFile(int $line, string $como, string $cldo, object $tempFile, string $idUser) {
+        $modulesCodes = [
+            "GEAD","GIST","GMPR","GMCO","GEEQ","COAC","GEPR",
+            "ANFA","PCSA","GPRS","GEPR","GDEL","ADSI","USPE"
+        ];
+
+        $clasifications = [
+            "AV","AU","CA","CE","CO","DP","FA","FI",
+            "FO","IN","LA","OR","PL","RE","VI"
+        ];
+
+        if(!in_array($como, $modulesCodes)){
+            return [false, "El código $como es inválido."];
+        }
+
+        if(!in_array($cldo, $clasifications)){
+            return [false, "La clasificación $cldo es inválida."];
+        }
+
+        $now = $this->functionsController->now();
+        $nowStr = $now->toDateTimeString();
+        $dateTimeArr = explode(' ', $nowStr);
+        $dateArr = explode('-', $dateTimeArr[0]);
+        $year = substr($dateArr[0], 2);
+
+        $fecr = "$year$dateArr[1]$dateArr[2]";
+        $sec = DB::table('S002V01TAFAL')->where([
+            ['AFAL_COMO', '=', $como],
+            ['AFAL_CLDO', '=', $cldo],
+            ['AFAL_NULI', '=', $line],
+        ])->orderBy('AFAL_NUSE', 'desc')->first();
+
+        $nuse = 1;
+        if(!is_null($sec)){
+            $nuse = intval($sec->AFAL_NUSE) + 1;
+        }
+
+        $fileNameArr = explode('.', $tempFile->ARTE_NOAR);
+        array_pop($fileNameArr);
+
+        $noar = implode('.', $fileNameArr);
+        $exte = $tempFile->ARTE_EXTE;
+
+        $ver = DB::table('S002V01TAFAL')->where([
+            ['AFAL_NULI', '=', $line],
+            ['AFAL_COMO', '=', $como],
+            ['AFAL_CLDO', '=', $cldo],
+            ['AFAL_NOAR', '=', $noar],
+            ['AFAL_EXTE', '=', $exte],
+        ])->orderBy('AFAL_NUVE', 'desc')->first();
+
+        $nuve = 1;
+        if(!is_null($ver)){
+            $nuve = intval($sec->AFAL_NUVE) + 1;
+        }
+
+        $tama = $tempFile->ARTE_TAMA;
+        $ubiFileArr = explode('tempFiles', $tempFile->ARTE_UBTE);
+        $ubic = $ubiFileArr[0] . 'files' . $ubiFileArr[1];
+
+        if(file_exists($tempFile->ARTE_UBTE)){
+            rename($tempFile->ARTE_UBTE, $ubic);
+            DB::table('S002V01TARTE')->where([
+                ['ARTE_IDAR', '=', $tempFile->ARTE_IDAR],
+                ['ARTE_NULI', '=', $line],
+            ])->update([
+                'ARTE_ESTA' => 'Eliminado',
+                'ARTE_USMO' => $idUser,
+                'ARTE_FEMO' => $nowStr,
+            ]);
+        }
+
+        $code = $line < 10 ? "0$line" : "$line";
+        $code .= "-$como-$cldo-$fecr-";
+
+        for($i = strlen($nuse); $i < 6; $i++){
+            $code .= "0";
+        }
+
+        $code .= "$nuse=";
+        $code .= $nuve < 10 ? "0$nuve=" : "$nuve=";
+        $code .= "$noar.$exte";
+
+        $usac = json_encode([$idUser]);
+
+        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' => $idUser,
+            'AFAL_FERE' => $nowStr
+        ]);
+
+        return [true, $code];
+    }
   
-  public function getPublicDocumentURL($id, $idUser, $line) {
-      DB::enableQueryLog();
-
-      $idUser = $this->encryptionController->decrypt($idUser);
-      if(!$idUser){
-          return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
-      }
-
-      $usr = DB::table('S002V01TUSUA')->where([
-          ['USUA_NULI', '=', $line],
-          ['USUA_IDUS', '=', $idUser],
-      ])->first();
-
-      if(is_null($usr)){
-          return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
-      }
-
-      $id = $this->encryptionController->decrypt($id);
-      if(!$id){
-          return $this->responseController->makeResponse(true, 'El ID del archivo solicitado no está encriptado correctamente.', [], 400);
-      }
-
-      $idArr = explode('=', $id);
-      $codeArr = explode('-', $idArr[0]);
-
-      $file = DB::table('S002V01TAFAL')->where([
-          ['AFAL_NULI', '=', $codeArr[0]],
-          ['AFAL_COMO', '=', $codeArr[1]],
-          ['AFAL_CLDO', '=', $codeArr[2]],
-          ['AFAL_FECR', '=', $codeArr[3]],
-          ['AFAL_NUSE', '=', $codeArr[4]],
-          ['AFAL_NUVE', '=', $idArr[1]],
-      ])->first();
-
-
-      if(is_null($file)){
-          return $this->responseController->makeResponse(true, 'El archivo solicitado no está registrado.', [], 404);
-      }
+    public function getPublicDocumentURL($id, $idUser, $line) {
+        DB::enableQueryLog();
+
+        $idUser = $this->encryptionController->decrypt($idUser);
+        if(!$idUser){
+            return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
+        }
+
+        $usr = DB::table('S002V01TUSUA')->where([
+            ['USUA_NULI', '=', $line],
+            ['USUA_IDUS', '=', $idUser],
+        ])->first();
+
+        if(is_null($usr)){
+            return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
+        }
+
+        $id = $this->encryptionController->decrypt($id);
+        if(!$id){
+            return $this->responseController->makeResponse(true, 'El ID del archivo solicitado no está encriptado correctamente.', [], 400);
+        }
+
+        $idArr = explode('=', $id);
+        $codeArr = explode('-', $idArr[0]);
+
+        $file = DB::table('S002V01TAFAL')->where([
+            ['AFAL_NULI', '=', $codeArr[0]],
+            ['AFAL_COMO', '=', $codeArr[1]],
+            ['AFAL_CLDO', '=', $codeArr[2]],
+            ['AFAL_FECR', '=', $codeArr[3]],
+            ['AFAL_NUSE', '=', $codeArr[4]],
+            ['AFAL_NUVE', '=', $idArr[1]],
+        ])->first();
+
+
+        if(is_null($file)){
+            return $this->responseController->makeResponse(true, 'El archivo solicitado no está registrado.', [], 404);
+        }
+
+        
+        $ubicArr = explode('storage', $file->AFAL_UBIC);
+        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
+            $publicUbi = "$ubicArr[0]public\\public_files\\$id";
+        } else {
+            $publicUbi = "$ubicArr[0]public_files\\$id";
+        }
+
+
+        if(!file_exists($publicUbi)){
+            copy($file->AFAL_UBIC, $publicUbi);
+        }
+
+        $apiURI = $this->functionsController->getApiURI();
+        $publicUbiStr = str_replace('C:\inetpub\wwwroot\\', $apiURI, $publicUbi);
+        $publicUbiStr = str_replace('\\', '/', $publicUbiStr);
+
+        $now = $this->functionsController->now();
+        $nowStr = $now->toDateTimeString();
+        $actions = DB::getQueryLog();
+        $name = $this->functionsController->joinName($usr->USUA_NOMB, $usr->USUA_APPA, $usr->USUA_APMA);
+
+        $idac = $this->functionsController->registerActivity(
+            $line,
+            'S002V01M04GDEL',
+            'S002V01F01ADDO',
+            'S002V01P01GEDO',
+            'Consulta',
+            "El usuario $name (" . $usr->USUA_IDUS . ") consultó la URL pública del archivo $id.",
+            $idUser,
+            $nowStr
+        );
+
+        $this->functionsController->registerLog($actions, $idUser, $nowStr, $idac, $line);
+        return $this->responseController->makeresponse(false, "EXITO", ['public_uri' => $publicUbiStr]);
+    }
+
+    public function privateGetPublicDocumentURL($id, $idUser, $line) {
+
+        $arrResponse = array('error' => false, 'msg' => '', 'response' => []);
+        DB::enableQueryLog();
+
+        $arrResponseCheckUser = $this->resourcesController->checkUserEnc($idUser, $line);
+        if ($arrResponseCheckUser['error']) {
+            $arrResponse['error'] = true;
+            $arrResponse['msg'] = $arrResponseCheckUser['msg'];
+            return $arrResponse;
+        }
+        $idUser = $arrResponseCheckUser['response'];
+       
+        $id = $this->encryptionController->decrypt($id);
+        if(!$id){
+            $arrResponse['error'] = true;
+            $arrResponse['msg'] = 'El ID del archivo solicitado no está encriptado correctamente.';
+            return $arrResponse;
+        }
+
+        $idArr = explode('=', $id);
+        $codeArr = explode('-', $idArr[0]);
+
+        $file = DB::table('S002V01TAFAL')->where([
+            ['AFAL_NULI', '=', $codeArr[0]],
+            ['AFAL_COMO', '=', $codeArr[1]],
+            ['AFAL_CLDO', '=', $codeArr[2]],
+            ['AFAL_FECR', '=', $codeArr[3]],
+            ['AFAL_NUSE', '=', $codeArr[4]],
+            ['AFAL_NUVE', '=', $idArr[1]],
+        ])->first();
+
+
+        if(is_null($file)){
+            $arrResponse['error'] = true;
+            $arrResponse['msg'] = 'El archivo solicitado no está registrado.';
+            return $arrResponse;
+        }
 
       
-      $ubicArr = explode('storage', $file->AFAL_UBIC);
-      $publicUbi = "$ubicArr[0]public_files\\$id";
-
-      if(!file_exists($publicUbi)){
-          copy($file->AFAL_UBIC, $publicUbi);
-      }
-
-      $apiURI = $this->functionsController->getApiURI();
-      $publicUbiStr = str_replace('C:\inetpub\wwwroot\\', $apiURI, $publicUbi);
-      $publicUbiStr = str_replace('\\', '/', $publicUbiStr);
-
-      $now = $this->functionsController->now();
-      $nowStr = $now->toDateTimeString();
-      $actions = DB::getQueryLog();
-      $name = $this->functionsController->joinName($usr->USUA_NOMB, $usr->USUA_APPA, $usr->USUA_APMA);
-
-      $idac = $this->functionsController->registerActivity(
-          $line,
-          'S002V01M04GDEL',
-          'S002V01F01ADDO',
-          'S002V01P01GEDO',
-          'Consulta',
-          "El usuario $name (" . $usr->USUA_IDUS . ") consultó la URL pública del archivo $id.",
-          $idUser,
-          $nowStr
-      );
-
-      $this->functionsController->registerLog($actions, $idUser, $nowStr, $idac, $line);
-      return $this->responseController->makeresponse(false, "EXITO", ['public_uri' => $publicUbiStr]);
-  }
+        $ubicArr = explode('storage', $file->AFAL_UBIC);
+
+        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
+            $publicUbi = "$ubicArr[0]public\public_files\\$id";
+        } else {
+            $publicUbi = "$ubicArr[0]public_files\\$id";
+        }
+        
+        if(!file_exists($publicUbi)){
+            copy($file->AFAL_UBIC, $publicUbi);
+        }
+
+        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
+            $apiURI = 'http://192.168.100.105:8000/';
+            $publicUbiStr = str_replace('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public\\', $apiURI, $publicUbi);
+        } else {
+            $apiURI = $this->functionsController->getApiURI();
+            $publicUbiStr = str_replace('C:\inetpub\wwwroot\\', $apiURI, $publicUbi);  
+        }
+
+        $publicUbiStr = str_replace('\\', '/', $publicUbiStr);
+
+        $arrResponse['response'] = ['public_uri' => $publicUbiStr];
+
+        return $arrResponse;
+    }
 
   public function getFileAccess($id, $idUser, $line) {
       DB::enableQueryLog();

+ 67 - 7
sistema-mantenimiento-back/app/Http/Controllers/EquipmentManagementController.php

@@ -18,7 +18,11 @@ class EquipmentManagementController extends Controller{
         $this->responseController = new ResponseController();
         $this->encryptionController = new EncryptionController();
         $this->functionsController = new FunctionsController();
-        $this->templatesUbic = "C:\inetpub\wwwroot\sam\storage\app\public\pdf_templates\\01_05_GEEQ\\";
+        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
+            $this->templatesUbic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\public\pdf_templates\\01_05_GEEQ\\";
+        } else {
+            $this->templatesUbic = "C:\inetpub\wwwroot\sam\storage\app\public\pdf_templates\\01_05_GEEQ\\";
+        }
         $this->documentManagementController = new DocumentManagementController();
     }
 
@@ -1600,7 +1604,7 @@ class EquipmentManagementController extends Controller{
         return $this->responseController->makeResponse(false, 'EXITO.');
     }
 
-    public function saveEquipmentPreCodifiedWarehouse(Request $request) {
+    public function saveEquipmentPreCodifiedStock(Request $request) {
         DB::enableQueryLog();
         $validator = Validator::make($request->all(), [
             'id_user' => 'required|string',
@@ -2021,7 +2025,7 @@ class EquipmentManagementController extends Controller{
                 ])->first();
                 // Se verifica que exista el código de serie
                 if(!is_null($serialNmberDB)){
-                    $serialNumberStr = $serialNmberDB->EQUI_COEQ;
+                    $serialNumberStr = $serialNmberDB->PCEQ_CPGE;
                     return $this->responseController->makeResponse(true, "El número de serie $serialNumber enviado ya se encuentra relacionado al equipamiento $serialNumberStr.", [], 401);
                 }
             }
@@ -2438,8 +2442,10 @@ class EquipmentManagementController extends Controller{
             ['PCEQ_NULI', '=', $line],
             ['PCEQ_ESRE', '=', 'Revisión'],
         ])->get()->all();
+        
 
         $idUserEnc = $this->encryptionController->encrypt($idUser);
+        
         foreach($pendingEquipments as $key=>$equipment){
             $equipment->IDREG = $this->encryptionController->encrypt($equipment->IDREG);
             $equipment->CODIGO = $this->encryptionController->encrypt($equipment->CODIGO);
@@ -2448,13 +2454,12 @@ class EquipmentManagementController extends Controller{
             $imagesGalleryFn = [];
             foreach($imagesGalleryArr as $imageCode){
                 $imageCodeEnc = $this->encryptionController->encrypt($imageCode);
-                $publicUri = $this->documentManagementController->getPublicDocumentURL(
+                $response = $this->documentManagementController->privateGetPublicDocumentURL(
                     $imageCodeEnc,
                     $idUserEnc,
                     $line
                 );
 
-                $response = json_decode($publicUri->original, true);
                 if($response['error']){
                     return $this->responseController->makeresponse(true, $response['msg'], [], 500);
                 }else{
@@ -2466,7 +2471,7 @@ class EquipmentManagementController extends Controller{
             $equipment->GALERIA_IMAGENES = json_encode($imagesGalleryFn);
             $equipment->TIPO_EQUIPAMIENTO = $this->encryptionController->encrypt($equipment->TIPO_EQUIPAMIENTO);
             $equipment->MODELO_EQUIPAMIENTO = $this->encryptionController->encrypt($equipment->MODELO_EQUIPAMIENTO);
-
+            
             $pendingEquipments[$key] = $equipment;
         }
 
@@ -2585,9 +2590,9 @@ class EquipmentManagementController extends Controller{
         $originLocationFilt = array_filter($locationsArrDec, function ($v, $k) use ($originLocation) {
             return $v['CODE'] == $originLocation;
         }, ARRAY_FILTER_USE_BOTH);
-
         $pendingEquipment->UBICACION_ORIGEN = end($originLocationFilt)['LOCATION'] . " (" . $pendingEquipment->UBICACION_ORIGEN . ")";
         $levelsArr = [];
+
     
         for($i = 5; $i > 0; $i--){
             $levelsArr[] = [
@@ -2784,6 +2789,8 @@ class EquipmentManagementController extends Controller{
             return $this->responseController->makeResponse(true, 'El pre-registro se encuentra aprobado.', [], 400);
         }
 
+
+
         $now = $this->functionsController->now();
         $nowStr = $now->toDateTimeString();
         if($form['status'] == 'Rechazado'){
@@ -2902,6 +2909,59 @@ class EquipmentManagementController extends Controller{
             ]);
         }
 
+        if ($pendingEquipment->PCEQ_TICO === '7') {
+            try {
+                $star = (array) DB::table('S002V01TSTAR')
+                    ->where('STAR_IDPC', '=', $pendingEquipment->PCEQ_IDPR)
+                    ->where('STAR_ESTA', '=', 'Pendiente')
+                    ->where('STAR_NULI', '=', $form['linea'])
+                    ->first();
+            } catch (\Throwable $th) {
+                return $this->responseController->makeResponse(true, 'Ocurrió un error al obtener los artículos en Stock.', [], 500); 
+            }
+
+            if ( !empty($star) && !is_null($star) ) {
+
+                try {
+                    $validateUpdate = DB::table('S002V01TSTAR')
+                        ->where('STAR_IDPC', '=', $pendingEquipment->PCEQ_IDPR)
+                        ->where('STAR_ESTA', '=', 'Pendiente')
+                        ->where('STAR_NULI', '=', $form['linea'])
+                        ->update([
+                            'STAR_ESTA' => 'Activo',
+                            'STAR_USMO' => $idUser,
+                            'STAR_FEMO' => $nowStr,
+                            'STAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
+                        ]);
+                } catch (\Throwable $th) {
+                    return $this->responseController->makeResponse(true, 'Ocurrió un al actualizar el stock.', [], 500); 
+                }
+                if (!$validateUpdate) {
+                    return $this->responseController->makeResponse(true, 'No se pudo actualizar la información en stock.', [], 500); 
+                }
+
+
+                try {
+                    $validateUpdate = DB::table('S002V01TUBAR')
+                        ->where('UBAR_IDST', '=', $star['STAR_IDST'])
+                        ->where('UBAR_ESTA', '=', 'Pendiente')
+                        ->where('UBAR_NULI', '=', $form['linea'])
+                        ->update([
+                            'UBAR_COUB' => $previewCode,
+                            'UBAR_ESTA' => 'Activo',
+                            'UBAR_USMO' => $idUser,
+                            'UBAR_FEMO' => $nowStr,
+                            'UBAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
+                        ]);
+                } catch (\Throwable $th) {
+                    return $this->responseController->makeResponse(true, 'Ocurrió un al actualizar el stock.', [], 500); 
+                }
+                if (!$validateUpdate) {
+                    return $this->responseController->makeResponse(true, 'No se pudo actualizar la información en stock.', [], 500); 
+                }
+            }
+        }
+
         $actions = DB::getQueryLog();
         $name = $this->functionsController->joinName($usr->USUA_NOMB, $usr->USUA_APPA, $usr->USUA_APMA);
         

+ 0 - 69
sistema-mantenimiento-back/app/Http/Controllers/ResourcesController.php

@@ -814,73 +814,4 @@ class ResourcesController extends Controller
         return $arrResponse;
     }
 
-
-    public function getPublicDocumentURL($id, $idUser, $line) {
-
-        $arrResponse = array('error' => false, 'msg' => '', 'response' => []);
-        DB::enableQueryLog();
-
-        
-
-        $arrResponseCheckUser = $this->checkUserEnc($idUser, $line);
-        if ($arrResponseCheckUser['error']) {
-            $arrResponse['error'] = true;
-            $arrResponse['msg'] = $arrResponseCheckUser['msg'];
-            return $arrResponse;
-        }
-        $idUser = $arrResponseCheckUser['response'];
-       
-        $id = $this->encController->decrypt($id);
-        if(!$id){
-            $arrResponse['error'] = true;
-            $arrResponse['msg'] = 'El ID del archivo solicitado no está encriptado correctamente.';
-            return $arrResponse;
-        }
-
-        $idArr = explode('=', $id);
-        $codeArr = explode('-', $idArr[0]);
-
-        $file = DB::table('S002V01TAFAL')->where([
-            ['AFAL_NULI', '=', $codeArr[0]],
-            ['AFAL_COMO', '=', $codeArr[1]],
-            ['AFAL_CLDO', '=', $codeArr[2]],
-            ['AFAL_FECR', '=', $codeArr[3]],
-            ['AFAL_NUSE', '=', $codeArr[4]],
-            ['AFAL_NUVE', '=', $idArr[1]],
-        ])->first();
-
-
-        if(is_null($file)){
-            $arrResponse['error'] = true;
-            $arrResponse['msg'] = 'El archivo solicitado no está registrado.';
-            return $arrResponse;
-        }
-
-      
-        $ubicArr = explode('storage', $file->AFAL_UBIC);
-
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $publicUbi = "$ubicArr[0]public\public_files\\$id";
-        } else {
-            $publicUbi = "$ubicArr[0]public_files\\$id";
-        }
-        
-        if(!file_exists($publicUbi)){
-            copy($file->AFAL_UBIC, $publicUbi);
-        }
-
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $apiURI = 'http://192.168.100.105:8000/';
-            $publicUbiStr = str_replace('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public\\', $apiURI, $publicUbi);
-        } else {
-            $apiURI = $this->functionsController->getApiURI();
-            $publicUbiStr = str_replace('C:\inetpub\wwwroot\\', $apiURI, $publicUbi);  
-        }
-
-        $publicUbiStr = str_replace('\\', '/', $publicUbiStr);
-
-        $arrResponse['response'] = ['public_uri' => $publicUbiStr];
-
-        return $arrResponse;
-    }
 }

+ 240 - 197
sistema-mantenimiento-back/app/Http/Controllers/StockController.php

@@ -33,6 +33,182 @@ class StockController extends Controller
         $this->functionsController = new FunctionsController();
     }
 
+    // Crear Artículo en Stock
+    public function createArtitleWithoutOrder(Request $request) {
+        $validator = Validator::make($request->all(), [
+            'ARTICULO' => 'required',
+            'MODELO' => 'required',
+            'CODIGO_MODELO' => 'required',
+            'FAMILIA' => 'required',
+            'SUBFAMILIA' => 'required',
+            'UNIDAD' => 'required',
+            'CODIGO_BARRAS' => 'required',
+            'CANTIDAD' => 'required',
+            'STOCK_MINIMO' => 'required',
+            'STOCK_MAXIMO' => 'required',
+            'REPARACION' => 'required|boolean',
+            'CONSUMIBLE' => 'required|boolean',
+            'PELIGROSO' => 'required|boolean',
+            // 'FECHA_VENCIMIENTO' => '',
+            // 'PROVEEDOR' => 'required',
+            'IMAGEN' => 'required',
+            'NUMERO_LINEA' => 'required',
+            'USUARIO' => 'required',
+        ]);
+
+        if ($validator->fails()) {
+            return $this->responseController->makeResponse(
+                true,
+                "ERR_STOCK_REG000: Se encontraron uno o más errores.",
+                $this->responseController->makeErrors($validator->errors()->messages()),
+                401
+            );
+        }
+        DB::beginTransaction();
+        $requestData = $request->all();
+        try {
+            $user = $this->encController->decrypt($requestData['USUARIO']);
+        } catch (\Throwable $th) {
+            DB::rollBack();
+            return $this->responseController->makeResponse(true, "ERR_STOCK_REG001: Ocurrió un error al obtener el usuario.", $th->getMessage(), 500);
+        }
+
+        try {
+            $validateFamily = DB::table('S002V01TFAMI')
+                ->where('FAMI_COFA','=', $requestData['FAMILIA'])
+                ->where('FAMI_NULI','=', $requestData['NUMERO_LINEA'])
+                ->where('FAMI_ESTA','=','Activo')
+                ->exists();
+        } catch (\Throwable $th) {
+            DB::rollBack();
+            return $this->responseController->makeResponse(true, "ERR_STOCK_REG002: Ocurrió un error al validar la familia.", $th->getMessage(), 500);
+        }
+        if (!$validateFamily) {
+            DB::rollBack();
+            return $this->responseController->makeResponse(true, "ERR_STOCK_REG003: La familia no existe.", [], 500);
+        }
+
+        try {
+            $validateSubfamily = DB::table('S002V01TSUBF')
+                ->where('SUBF_COSU','=', $requestData['SUBFAMILIA'])
+                ->where('SUBF_NULI','=', $requestData['NUMERO_LINEA'])
+                ->where('SUBF_ESTA','=','Activo')
+                ->exists();
+        } catch (\Throwable $th) {
+            DB::rollBack();
+            return $this->responseController->makeResponse(true, "ERR_STOCK_REG004: Ocurrió un error al validar la subfamilia.", $th->getMessage(), 500);
+        }
+        if (!$validateSubfamily) {
+            DB::rollBack();
+            return $this->responseController->makeResponse(true, "ERR_STOCK_REG005: La subfamilia no existe.", [], 500);
+        }
+        
+        try {
+            $validateUnit = DB::table('S002V01TUNID')
+                ->where('UNID_IDUN','=', $requestData['UNIDAD'])
+                ->where('UNID_NULI','=', $requestData['NUMERO_LINEA'])
+                ->where('UNID_ESTA','=','Activo')
+                ->exists();
+        } catch (\Throwable $th) {
+            DB::rollBack();
+            return $this->responseController->makeResponse(true, "ERR_STOCK_REG006: Ocurrió un error al validar la unidad.", $th->getMessage(), 500);
+        }
+        if (!$validateUnit) {
+            DB::rollBack();
+            return $this->responseController->makeResponse(true, "ERR_STOCK_REG007: La unidad no existe.", [], 500);
+        }
+
+        $requestData['PROVEEDOR'] = $requestData['PROVEEDOR'] === '' ? null : $requestData['PROVEEDOR'];
+
+        if (!is_null($requestData['PROVEEDOR'])) {
+            try {
+                $validateUnit = DB::table('S002V01TPROV')
+                    ->where('PROV_NUPR','=', $requestData['PROVEEDOR'])
+                    ->where('PROV_NULI','=', $requestData['NUMERO_LINEA'])
+                    ->where('PROV_ESTA','=','Activo')
+                    ->exists();
+            } catch (\Throwable $th) {
+                DB::rollBack();
+                return $this->responseController->makeResponse(true, "ERR_STOCK_REG008: Ocurrió un error al validar el proveedor.", $th->getMessage(), 500);
+            }
+            if (!$validateUnit) {
+                DB::rollBack();
+                return $this->responseController->makeResponse(true, "ERR_STOCK_REG009: El proveedor no existe.", [], 500);
+            }
+        }
+       
+
+        $arrCodeImages = array();
+        foreach ($requestData['IMAGEN'] as $key => $encIdFile) {
+
+            $idFile = $this->encController->decrypt($encIdFile);
+            $tempFile = DB::table('S002V01TARTE')->where([
+                ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
+                ['ARTE_IDAR', '=', $idFile],
+            ])->first();
+
+            if(is_null($tempFile)){
+                return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG006: El archivo consultado no está registrado', [], 404);
+            }else if($tempFile->ARTE_ESTA == 'Eliminado'){
+                return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG007: El archivo consultado está eliminado', [], 404);
+            }
+            $fileResponse = $this->documentManagementController->moveFinalFile(
+                intval($requestData['NUMERO_LINEA']),
+                'GIST',
+                'FO',
+                $tempFile,
+                $user,
+            );
+            if(!$fileResponse[0]){
+                return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG008: '.$fileResponse[1], [], 400);
+            }
+            $arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
+        }
+        $jsonImages = json_encode($arrCodeImages);
+
+        $now = $this->functionsController->now();
+        $currentDate = $now->toDateTimeString();
+
+        try {
+            $validateRegister = DB::table('S002V01TSTAR')->insert([
+                // 'STAR_CODI' => $requestData['CODIGO_STOCK'],
+                'STAR_ARTI' => $requestData['ARTICULO'],
+                'STAR_MODE' => $requestData['MODELO'],
+                'STAR_COMO' => $requestData['CODIGO_MODELO'],
+                'STAR_IDFA' => $requestData['FAMILIA'],
+                'STAR_IDSU' => $requestData['SUBFAMILIA'],
+                'STAR_NUPR' => $requestData['PROVEEDOR'],
+                'STAR_IDUN' => $requestData['UNIDAD'],
+                'STAR_COBA' => $requestData['CODIGO_BARRAS'],
+                'STAR_CANT' => $requestData['CANTIDAD'],
+                'STAR_STMI' => $requestData['STOCK_MINIMO'],
+                'STAR_STMA' => $requestData['STOCK_MAXIMO'],
+                'STAR_REPA' => $requestData['REPARACION'],
+                'STAR_CONS' => $requestData['CONSUMIBLE'],
+                'STAR_PELI' => $requestData['PELIGROSO'],
+                'STAR_FEVE' => $requestData['FECHA_VENCIMIENTO'],
+                'STAR_IMAG' => $jsonImages,
+                'STAR_TIAD' => 'Sin Pedido',
+                'STAR_NULI' => $requestData['NUMERO_LINEA'],
+                'STAR_USRE' => $user,
+                'STAR_FERE' => $currentDate,
+                'STAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
+            ]);
+        } catch (\Throwable $th) {
+            DB::rollBack();
+            return $this->responseController->makeResponse(true, "ERR_STOCK_REG011: Ocurrió un error al registrar el artículo.", $th->getMessage(), 500);
+        }
+
+        if (!$validateRegister) {
+            DB::rollBack();
+            return $this->responseController->makeResponse(true, "ERR_STOCK_REG012: No se pudo registrar el artículo.", [], 500);
+        }
+
+        DB::commit();
+        return $this->responseController->makeResponse(false, "EXITO: Registro Exitoso");
+    }
+
+    // FUNCIÓN GESTIÓN DE ALMACENES
     public function getWarehouse( $user, $line ) {
         $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
         if ($arrResponseCheckUser['error']) {
@@ -599,182 +775,6 @@ class StockController extends Controller
 
     }
 
-    // Crear Artículo en Stock
-    public function createArtitleWithoutOrder(Request $request) {
-        $validator = Validator::make($request->all(), [
-            'ARTICULO' => 'required',
-            'MODELO' => 'required',
-            'CODIGO_MODELO' => 'required',
-            'FAMILIA' => 'required',
-            'SUBFAMILIA' => 'required',
-            'UNIDAD' => 'required',
-            'CODIGO_BARRAS' => 'required',
-            'CANTIDAD' => 'required',
-            'STOCK_MINIMO' => 'required',
-            'STOCK_MAXIMO' => 'required',
-            'REPARACION' => 'required|boolean',
-            'CONSUMIBLE' => 'required|boolean',
-            'PELIGROSO' => 'required|boolean',
-            // 'FECHA_VENCIMIENTO' => '',
-            // 'PROVEEDOR' => 'required',
-            'IMAGEN' => 'required',
-            'NUMERO_LINEA' => 'required',
-            'USUARIO' => 'required',
-        ]);
-
-        if ($validator->fails()) {
-            return $this->responseController->makeResponse(
-                true,
-                "ERR_STOCK_REG000: Se encontraron uno o más errores.",
-                $this->responseController->makeErrors($validator->errors()->messages()),
-                401
-            );
-        }
-        DB::beginTransaction();
-        $requestData = $request->all();
-        try {
-            $user = $this->encController->decrypt($requestData['USUARIO']);
-        } catch (\Throwable $th) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, "ERR_STOCK_REG001: Ocurrió un error al obtener el usuario.", $th->getMessage(), 500);
-        }
-
-        try {
-            $validateFamily = DB::table('S002V01TFAMI')
-                ->where('FAMI_COFA','=', $requestData['FAMILIA'])
-                ->where('FAMI_NULI','=', $requestData['NUMERO_LINEA'])
-                ->where('FAMI_ESTA','=','Activo')
-                ->exists();
-        } catch (\Throwable $th) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, "ERR_STOCK_REG002: Ocurrió un error al validar la familia.", $th->getMessage(), 500);
-        }
-        if (!$validateFamily) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, "ERR_STOCK_REG003: La familia no existe.", [], 500);
-        }
-
-        try {
-            $validateSubfamily = DB::table('S002V01TSUBF')
-                ->where('SUBF_COSU','=', $requestData['SUBFAMILIA'])
-                ->where('SUBF_NULI','=', $requestData['NUMERO_LINEA'])
-                ->where('SUBF_ESTA','=','Activo')
-                ->exists();
-        } catch (\Throwable $th) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, "ERR_STOCK_REG004: Ocurrió un error al validar la subfamilia.", $th->getMessage(), 500);
-        }
-        if (!$validateSubfamily) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, "ERR_STOCK_REG005: La subfamilia no existe.", [], 500);
-        }
-        
-        try {
-            $validateUnit = DB::table('S002V01TUNID')
-                ->where('UNID_IDUN','=', $requestData['UNIDAD'])
-                ->where('UNID_NULI','=', $requestData['NUMERO_LINEA'])
-                ->where('UNID_ESTA','=','Activo')
-                ->exists();
-        } catch (\Throwable $th) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, "ERR_STOCK_REG006: Ocurrió un error al validar la unidad.", $th->getMessage(), 500);
-        }
-        if (!$validateUnit) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, "ERR_STOCK_REG007: La unidad no existe.", [], 500);
-        }
-
-        $requestData['PROVEEDOR'] = $requestData['PROVEEDOR'] === '' ? null : $requestData['PROVEEDOR'];
-
-        if (!is_null($requestData['PROVEEDOR'])) {
-            try {
-                $validateUnit = DB::table('S002V01TPROV')
-                    ->where('PROV_NUPR','=', $requestData['PROVEEDOR'])
-                    ->where('PROV_NULI','=', $requestData['NUMERO_LINEA'])
-                    ->where('PROV_ESTA','=','Activo')
-                    ->exists();
-            } catch (\Throwable $th) {
-                DB::rollBack();
-                return $this->responseController->makeResponse(true, "ERR_STOCK_REG008: Ocurrió un error al validar el proveedor.", $th->getMessage(), 500);
-            }
-            if (!$validateUnit) {
-                DB::rollBack();
-                return $this->responseController->makeResponse(true, "ERR_STOCK_REG009: El proveedor no existe.", [], 500);
-            }
-        }
-       
-
-        $arrCodeImages = array();
-        foreach ($requestData['IMAGEN'] as $key => $encIdFile) {
-
-            $idFile = $this->encController->decrypt($encIdFile);
-            $tempFile = DB::table('S002V01TARTE')->where([
-                ['ARTE_NULI', '=', $requestData['NUMERO_LINEA']],
-                ['ARTE_IDAR', '=', $idFile],
-            ])->first();
-
-            if(is_null($tempFile)){
-                return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG006: El archivo consultado no está registrado', [], 404);
-            }else if($tempFile->ARTE_ESTA == 'Eliminado'){
-                return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG007: El archivo consultado está eliminado', [], 404);
-            }
-            $fileResponse = $this->documentManagementController->moveFinalFile(
-                intval($requestData['NUMERO_LINEA']),
-                'GIST',
-                'FO',
-                $tempFile,
-                $user,
-            );
-            if(!$fileResponse[0]){
-                return $this->responseController->makeResponse(true, 'ERR_ARTITLE_REG008: '.$fileResponse[1], [], 400);
-            }
-            $arrCodeImages[] = $this->encController->encrypt($fileResponse[1]);
-        }
-        $jsonImages = json_encode($arrCodeImages);
-
-        $now = $this->functionsController->now();
-        $currentDate = $now->toDateTimeString();
-
-        try {
-            $validateRegister = DB::table('S002V01TSTAR')->insert([
-                // 'STAR_CODI' => $requestData['CODIGO_STOCK'],
-                'STAR_ARTI' => $requestData['ARTICULO'],
-                'STAR_MODE' => $requestData['MODELO'],
-                'STAR_COMO' => $requestData['CODIGO_MODELO'],
-                'STAR_IDFA' => $requestData['FAMILIA'],
-                'STAR_IDSU' => $requestData['SUBFAMILIA'],
-                'STAR_NUPR' => $requestData['PROVEEDOR'],
-                'STAR_IDUN' => $requestData['UNIDAD'],
-                'STAR_COBA' => $requestData['CODIGO_BARRAS'],
-                'STAR_CANT' => $requestData['CANTIDAD'],
-                'STAR_STMI' => $requestData['STOCK_MINIMO'],
-                'STAR_STMA' => $requestData['STOCK_MAXIMO'],
-                'STAR_REPA' => $requestData['REPARACION'],
-                'STAR_CONS' => $requestData['CONSUMIBLE'],
-                'STAR_PELI' => $requestData['PELIGROSO'],
-                'STAR_FEVE' => $requestData['FECHA_VENCIMIENTO'],
-                'STAR_IMAG' => $jsonImages,
-                'STAR_TIAD' => 'Sin Pedido',
-                'STAR_NULI' => $requestData['NUMERO_LINEA'],
-                'STAR_USRE' => $user,
-                'STAR_FERE' => $currentDate,
-                'STAR_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
-            ]);
-        } catch (\Throwable $th) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, "ERR_STOCK_REG011: Ocurrió un error al registrar el artículo.", $th->getMessage(), 500);
-        }
-
-        if (!$validateRegister) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, "ERR_STOCK_REG012: No se pudo registrar el artículo.", [], 500);
-        }
-
-        DB::commit();
-        return $this->responseController->makeResponse(false, "EXITO: Registro Exitoso");
-    }
-
-
     public function getAreaByWarehouse($idWarehouse, $user, $line) {
         try {
             $idWarehouse = $this->encController->decrypt($idWarehouse);
@@ -1035,22 +1035,6 @@ class StockController extends Controller
         }
 
 
-        try {
-            $validateExistCode = DB::table('S002V01TAREA')
-                ->where('AREA_NULI', '=', $requestData['NUMERO_LINEA'])
-                ->where('AREA_COAR', '!=', $idArea)
-                ->where('AREA_ESTA', '=', 'Activo')
-                ->exists();
-        } catch (\Throwable $th) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, 'ERR_AREA_UPD007: Ocurrió un error al verificar el código del área.', $th->getMessage(), 500);
-        }
-        if ($validateExistCode) {
-            DB::rollBack();
-            return $this->responseController->makeResponse(true, 'ERR_AREA_UPD008: El código del área ya se encuentra registrado.', [], 406);
-        }
-
-
         $now = $this->functionsController->now();
         $currentDate = $now->toDateTimeString();
 
@@ -1206,7 +1190,6 @@ class StockController extends Controller
         return $this->responseController->makeResponse(false, "ÉXITO: Eliminación Exitosa");
     }
 
-
     public function getLevelByAreaWarehouse($idWarehouse, $idArea, $user, $line) {
         try {
             $idWarehouse = $this->encController->decrypt($idWarehouse);
@@ -1687,8 +1670,6 @@ class StockController extends Controller
         return $this->responseController->makeResponse(false, "ÉXITO: Eliminación Exitosa");
     }
 
-
-
     public function getZoneByLevelAreaWarehouse($idWarehouse, $idArea, $idLevel, $user, $line) {
         try {
             $idWarehouse = $this->encController->decrypt($idWarehouse);
@@ -2224,7 +2205,7 @@ class StockController extends Controller
         return $this->responseController->makeResponse(false, "ÉXITO: Eliminación Exitosa");
     }
 
-
+    // FUNCIÓN RECEPCIÓN DE ARTÍCULOS
     public function registerToStock(Request $request) {
         $validator = Validator::make($request->all(), [
             'WAREHOUSE' => 'required|string',
@@ -2445,7 +2426,7 @@ class StockController extends Controller
         }
         if (is_null($orden)) {
             DB::rollBack();
-            return $this->responseController->makeResponse(true, 'La orden de compra no exite.', [], 500);
+            return $this->responseController->makeResponse(true, 'La orden de compra no existe.', [], 500);
         }
 
         $now = $this->functionsController->now();
@@ -2782,4 +2763,66 @@ class StockController extends Controller
         DB::commit();
         return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
     }
+
+    // FUNCIÓN INTERCAMBIO DE ARTICULOS ENTRE ALMACENES
+    public function getCurrentLocationArtitles($user, $line) {
+        try {
+            $arrStockArtitle = DB::table('S002V01TSTAR')
+                ->where('STAR_NULI', '=', $line)
+                ->where('STAR_ESTA', '=', 'Activo')
+                ->where('INST_NULI', '=', $line)
+                ->where('INST_ESTA', '=', 'Activo')
+                ->where('UBAR_ESTA', '=', 'Activo')
+                ->join('S002V01TUBAR', 'UBAR_IDST', '=', 'STAR_IDST')
+                ->join('S002V01TINST', 'INST_IDIS', '=', 'STAR_IDIS')
+                ->join('S002V01TFAMI', 'FAMI_COFA', '=', 'INST_COFA')
+                ->join('S002V01TSUBF', 'SUBF_COSU', '=', 'INST_COSU')
+
+                ->join('S002V01TALMA', 'ALMA_COAL', '=', 'UBAR_COAL')
+                ->join('S002V01TAREA', 'AREA_COAR', '=', 'UBAR_COAR')
+                ->join('S002V01TNIVE', 'NIVE_CONI', '=', 'UBAR_CONI')
+                ->join('S002V01TZONA', 'ZONA_COZO', '=', 'UBAR_COZO')
+                ->get([
+                    'STAR_IDST AS ID_STOCK',
+                    'INST_IDIS AS ID_INFORMACION_STOCK',
+                    'FAMI_NOFA AS NOMBRE_FAMILIA',
+                    'SUBF_NOSU AS NOMBRE_SUBFAMILIA',
+                    'INST_ARTI AS ARTITULO',
+                    'INST_MODE AS MODELO',
+                    'INST_COMO AS CODIGO_MODELO',
+                    'INST_IMAG AS IMAGENES',
+                    'UBAR_COUB AS CODIGO',
+                    DB::raw('CONCAT(ALMA_NOAL, " (", ALMA_COAL, ")") AS NOMBRE_ALMACEN'),
+                    DB::raw('CONCAT(AREA_NOAR, " (", AREA_COAR, ")") AS NOMBRE_AREA'),
+                    DB::raw('CONCAT(NIVE_NONI, " (", NIVE_CONI, ")") AS NOMBRE_NIVEL'),
+                    DB::raw('CONCAT(ZONA_NOZO, " (", ZONA_COZO, ")") AS NOMBRE_ZONA'),
+                ]);
+            $arrStockArtitle = json_decode(json_encode($arrStockArtitle), true);
+        } catch (\Throwable $th) {
+            return $this->responseController->makeResponse(true, 'Ocurrió un error al obtener la información del stock.', $th->getMessage(), 500);
+        }
+
+        foreach ($arrStockArtitle as $key => $stockArtitle) {
+            $imagesGallery = [];
+            $arrImages = json_decode($stockArtitle['IMAGENES']);
+            foreach($arrImages as $image) {
+                $imageCodeEnc = $this->encController->encrypt($image);
+                $response = $this->documentManagementController->privateGetPublicDocumentURL(
+                    $imageCodeEnc,
+                    $user,
+                    $line
+                );
+                if($response['error']){
+                    return $this->responseController->makeresponse(true, $response['msg'], [], 500);
+                }
+                $imagesGallery[] = $response['response']['public_uri'];
+            }
+            $stockArtitle['IMAGENES'] = $imagesGallery;
+            $arrStockArtitle[$key] = $stockArtitle;
+        }
+
+        return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrStockArtitle);
+    }
+
+    // FUNCIÓN PARA JOSÉ LUIS
 }

+ 33 - 4
sistema-mantenimiento-back/routes/api.php

@@ -278,6 +278,7 @@ Route::middleware(['jwt.auth'])->group(function(){
     Route::post("/occupation/update",                                                   "App\Http\Controllers\EquipmentManagementController@updateOccupation");
     Route::post("/occupation/delete",                                                   "App\Http\Controllers\EquipmentManagementController@deleteOccupation");
     Route::post("/equipment/pre-codification",                                          "App\Http\Controllers\EquipmentManagementController@saveEquipmentPreCodified");
+    Route::post("/equipment/pre-codification-stock",                                    "App\Http\Controllers\EquipmentManagementController@saveEquipmentPreCodifiedStock");
     Route::post("/equipment/pre-codification/status/update",                            "App\Http\Controllers\EquipmentManagementController@changePreCodedEquipmentStatus");
     //Módulo gestión de mantenimiento correctivo
     Route::get("corrective-maintenance/get-work-orders/{idUser}/{line}",                "App\Http\Controllers\CorrectiveMaintenanceController@getWorkOrders");
@@ -459,13 +460,41 @@ Route::middleware(['jwt.auth'])->group(function(){
 
     
     // Module: GEIN
-    Route::post('inventory-management/register-artitle-without-order', [StockController::class, 'createArtitleWithoutOrder']);
+    Route::post('inventory-management/register-artitle-without-order',                  [StockController::class, 'createArtitleWithoutOrder']);
+
+    Route::get ('inventory-management/get-warehouse/{user}/{line}',                         [StockController::class, 'getWarehouse']);
+    Route::get ('inventory-management/get-warehouse-by-id/{idWarehouse}/{user}/{line}',     [StockController::class, 'getWarehouseById']);
+    Route::get ('inventory-management/get-warehouse-actives/{user}/{line}',                 [StockController::class, 'getWarehouseActives']);
+    Route::post('inventory-management/create-warehouse',                                    [StockController::class, 'createWarehouse']);
+    Route::put ('inventory-management/update-warehouse/{idWarehouse}',                      [StockController::class, 'updateWarehouse']);
+    Route::put ('inventory-management/delete-warehouse/{idWarehouse}',                      [StockController::class, 'deleteWarehouse']);
+
+    Route::get ('inventory-management/get-area-by-warehouse/{idWarehouse}/{user}/{line}',           [StockController::class, 'getAreaByWarehouse']);
+    Route::get ('inventory-management/get-area-by-id/{idArea}/{user}/{line}',                       [StockController::class, 'getAreaById']);
+    Route::get ('inventory-management/get-area-by-warehouse-actives/{idWarehouse}/{user}/{line}',   [StockController::class, 'getAreaByWarehouseActives']);
+    Route::post ('inventory-management/register-area',                                              [StockController::class, 'registerArea']);
+    Route::put ('inventory-management/update-area/{idArea}',                                        [StockController::class, 'updateArea']);
+    Route::put ('inventory-management/delete-area/{idArea}',                                        [StockController::class, 'deleteArea']);
+
+    Route::get ('inventory-management/get-level-by-area-warehouse/{idWarehouse}/{idArea}/{user}/{line}',            [StockController::class, 'getLevelByAreaWarehouse']);
+    Route::get ('inventory-management/get-level-by-id/{idLevel}/{user}/{line}',                                     [StockController::class, 'getLevelById']);
+    Route::get ('inventory-management/get-level-by-area-warehouse-actives/{idWarehouse}/{idArea}/{user}/{line}',    [StockController::class, 'getLevelByAreaWarehouseActives']);
+    Route::post('inventory-management/register-level',                                                              [StockController::class, 'registerLevel']);
+    Route::put ('inventory-management/update-level/{idLevel}',                                                      [StockController::class, 'updateLevel']);
+    Route::put ('inventory-management/delete-level/{idLevel}',                                                      [StockController::class, 'deleteLevel']);
+
+    Route::get ('inventory-management/get-zone-by-level-area-warehouse/{idWarehouse}/{idArea}/{idLevel}/{user}/{line}',         [StockController::class, 'getZoneByLevelAreaWarehouse']);
+    Route::get ('inventory-management/get-zone-by-id/{idZone}/{user}/{line}',                                                   [StockController::class, 'getZoneById']);
+    Route::get ('inventory-management/get-zone-by-level-area-warehouse-actives/{idWarehouse}/{idArea}/{idLevel}/{user}/{line}', [StockController::class, 'getZoneByLevelAreaWarehouseActive']);
+    Route::post('inventory-management/register-zone',                                                                           [StockController::class, 'registerZone']);
+    Route::put ('inventory-management/update-zone/{idZone}',                                                                    [StockController::class, 'updateZone']);
+    Route::put ('inventory-management/delete-zone/{idZone}',                                                                    [StockController::class, 'deleteZone']);
     
-    Route::get ('inventory-management/get-warehouse/{user}/{line}', [StockController::class, 'getWarehouse']);
-    Route::post('inventory-management/create-warehouse', [StockController::class, 'createWarehouse']);
+    Route::post ('inventory-management/register-to-stock', [StockController::class, 'registerToStock']);
     
+    Route::get ('inventory-management/get-current-location-artitles/{user}/{line}',      [StockController::class, 'getCurrentLocationArtitles']);
+
     // Localidad
-    
     Route::get ('catalog/get-payment-method-active/{line_number}',            [CatalogController::class, 'getPaymentMethodActive']);
     Route::get ('catalog/get-tax-regime-active/{line}',                       [CatalogController::class, 'getTaxRegimeActive']);
     Route::get ('catalog/get-coins-active/{line}',                            [CatalogController::class, 'getCatalogCoinsActive']);