Przeglądaj źródła

globalizacion de base_path

EmilianoOrtiz 2 miesięcy temu
rodzic
commit
61ed1e41cc

+ 10 - 27
sistema-mantenimiento-back/app/Http/Controllers/AcquisitionManagementController.php

@@ -4002,11 +4002,8 @@ class AcquisitionManagementController extends Controller
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
 
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
-        } else {
-            $ubic = "C:\inetpub\wwwroot\sam\storage\app\\" . $ubic;
-        }
+        
+        $ubic = $this->functionsController->getBasePath() . "\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$user]);
 
@@ -13067,12 +13064,9 @@ class AcquisitionManagementController extends Controller
         $noar = 'ficha_de_adquisición_' . $arrOrder['ORCO_NUOR'];
         $exte = 'xlsx';
 
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $filePath = 'C:/ITTEC/SAM/Dev/SistemaMantenimiento/sistema-mantenimiento-back/public/public_files/';    // API JEAN
-        } else {
-            $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';     // API QA
-        }
-
+        
+        $filePath = $this->functionsController->getBasePath() . '/public/public_files/';    // API JEAN
+        
         $fileName = $nuli.'-'.$como.'-'.$cldo.'-'.$fecr.'-'.$nuse.'='.$nuve.'='.$noar.'.'.$exte;
 
         $tempFile = $filePath.$fileName;
@@ -13106,11 +13100,7 @@ class AcquisitionManagementController extends Controller
 
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
-        } else {
-            $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
-        }
+        $ubic = $this->functionsController->getBasePath() . "\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$user]);
 
@@ -13649,12 +13639,8 @@ class AcquisitionManagementController extends Controller
         $exte = 'pdf';        
         
         
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $filePath = 'C:/ITTEC/SAM/Dev/SistemaMantenimiento/sistema-mantenimiento-back/public/public_files/';    // API JEAN
-        } else {
-            $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';     // API QA
-        }
-
+        $filePath = $this->functionsController->getBasePath() . '/public/public_files/';    // API JEAN
+        
         $fileName = $nuli.'-'.$como.'-'.$cldo.'-'.$fecr.'-'.$nuse.'='.$nuve.'='.$noar.'.'.$exte;
         
         $tempFile = $filePath . $fileName;
@@ -13670,11 +13656,8 @@ class AcquisitionManagementController extends Controller
         $ubic = Storage::putFile('files', new File($tempFile));
 
         $ubic = str_replace("/", "\\", $ubic);
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
-        } else {
-            $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
-        }
+        $ubic = $this->functionsController->getBasePath() . "\storage\app\\" . $ubic;
+        
         $tama = filesize($ubic);
         $usac = json_encode([$user]);
 

+ 6 - 6
sistema-mantenimiento-back/app/Http/Controllers/ControlPanelController.php

@@ -27,7 +27,7 @@ class ControlPanelController extends Controller{
         $this->responseController = new ResponseController();
         $this->encryptionController = new EncryptionController();
         $this->functionsController = new FunctionsController();
-        $this->filesUbic = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\public\global_resources\\';
+        $this->filesUbic = $this->functionsController->getBasePath() . '\storage\app\public\global_resources\\';
     }
 
     public function getPanels($idUser, $line) {
@@ -866,7 +866,7 @@ class ControlPanelController extends Controller{
         }
 
         $line = $line < 10 ? "0$line" : "$line";
-        $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';
+        $filePath = $this->functionsController->getBasePath() . '\public_files\\';
         $fileName = "$line-$como-$cldo-$fecr-$nuse=$nuve=$noar.$exte";
         
         $tempFile = $filePath . $fileName;
@@ -878,7 +878,7 @@ class ControlPanelController extends Controller{
         $writer->save($tempFile);
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
+        $ubic = $this->functionsController->getBasePath() . "\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$idUser]);
         unlink($tempFile);
@@ -1588,12 +1588,12 @@ class ControlPanelController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado', [], 404);
         }
 
-        $exportableSpreadsheetsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\public\global_resources\spreadsheets.sam');
+        $exportableSpreadsheetsExists = file_exists($this->functionsController->getBasePath() . '\storage\app\public\global_resources\spreadsheets.sam');
         if(!$exportableSpreadsheetsExists){
             return $this->responseController->makeResponse(true, 'El archivo de hojas de excel exportables no fue encontrado.', [], 500);
         }
 
-        $exportableSpreadsheetsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\public\global_resources\spreadsheets.sam');
+        $exportableSpreadsheetsStr = file_get_contents($this->functionsController->getBasePath() . '\storage\app\public\global_resources\spreadsheets.sam');
         $exportableSpreadsheetsDec = $this->encryptionController->decrypt($exportableSpreadsheetsStr);
         $exportableSpreadsheetsArr = json_decode($exportableSpreadsheetsDec, true);
 
@@ -3081,7 +3081,7 @@ class ControlPanelController extends Controller{
         }
 
         $line = $line < 10 ? "0$line" : "$line";
-        $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';
+        $filePath = $this->functionsController->getBasePath() . '\public_files\\';
         $fileName = "$line-$como-$cldo-$fecr-$nuse=$nuve=$noar.$exte";
         
         $tempFile = $filePath . $fileName;

+ 13 - 13
sistema-mantenimiento-back/app/Http/Controllers/CorrectiveMaintenanceController.php

@@ -35,7 +35,7 @@ class CorrectiveMaintenanceController extends Controller{
         $this->functionsController = new FunctionsController();
         $this->documentManagementController = new DocumentManagementController();
         $this->notificationsController = new NotificationsController();
-        $this->templatesUbic = "C:\inetpub\wwwroot\sam\storage\app\public\pdf_templates\\01_04_GMCO\\";
+        $this->templatesUbic = $this->functionsController->getBasePath() . "\storage\app\public\pdf_templates\\01_04_GMCO\\";
     }
 
     private function getSocketClient(){
@@ -2750,12 +2750,12 @@ class CorrectiveMaintenanceController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la petición no existe.', [], 404);
         }
 
-        $systemParamsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $systemParamsExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         if(!$systemParamsExists){
             return $this->responseController->makeResponse(true, 'El archivo de parámetros del sistema no fue encontrado.', [], 500);
         }
 
-        $paramsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $paramsStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         $paramsArr = json_decode($paramsStr, true);
 
         $ordersBuilder = DB::table('S002V01TOTCO')->select([
@@ -3065,7 +3065,7 @@ class CorrectiveMaintenanceController extends Controller{
         }
 
         $line = $form['linea'] < 10 ? "0$form[linea]" : "$form[linea]";
-        $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';
+        $filePath = $this->functionsController->getBasePath() .'\public_files\\';
         $fileName = "$line-$como-$cldo-$fecr-$nuse=$nuve=$noar.$exte";
         
         $tempFile = $filePath . $fileName;
@@ -3077,7 +3077,7 @@ class CorrectiveMaintenanceController extends Controller{
         $writer->save($tempFile);
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
+        $ubic = $this->functionsController->getBasePath() ."\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$idUser]);
         unlink($tempFile);
@@ -3396,12 +3396,12 @@ class CorrectiveMaintenanceController extends Controller{
         }
 
         $priorityDec = $this->encryptionController->decrypt($form['priority']);
-        $systemParamsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $systemParamsExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         if(!$systemParamsExists){
             return $this->responseController->makeResponse(true, 'El archivo de parámetros del sistema no fue encontrado.', [], 500);
         }
 
-        $paramsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $paramsStr = file_get_contents($this->functionsController->getBasePath() . '\storage\app\files\system-params.json');
         $paramsArr = json_decode($paramsStr, true);
         $orderPriorities = $paramsArr['order_priorities'];
 
@@ -5591,10 +5591,10 @@ class CorrectiveMaintenanceController extends Controller{
 
         $reportDataArr = json_decode($reportDataDec, true);
         $html = '';
-        $crrcLogo = file_get_contents("C:\inetpub\wwwroot\sam\storage\app\public\global_resources\logo_crrc.webp");
-        $ingeropLogo = file_get_contents("C:\inetpub\wwwroot\sam\storage\app\public\global_resources\logo_ingerop.png");
-        $stcLogo = file_get_contents("C:\inetpub\wwwroot\sam\storage\app\public\global_resources\logo_stc.webp");
-        $stcShortLogo = file_get_contents("C:\inetpub\wwwroot\sam\storage\app\public\global_resources\logo_stc_small.png");
+        $crrcLogo = file_get_contents($this->functionsController->getBasePath() . "\storage\app\public\global_resources\logo_crrc.webp");
+        $ingeropLogo = file_get_contents($this->functionsController->getBasePath() ."\storage\app\public\global_resources\logo_ingerop.png");
+        $stcLogo = file_get_contents($this->functionsController->getBasePath() ."\storage\app\public\global_resources\logo_stc.webp");
+        $stcShortLogo = file_get_contents($this->functionsController->getBasePath() ."\storage\app\public\global_resources\logo_stc_small.png");
 
         $crrcLogoStr = "data:image/svg+xml;base64," . base64_encode($crrcLogo);
         $ingeropLogoStr = "data:image/svg+xml;base64," . base64_encode($ingeropLogo);
@@ -5671,7 +5671,7 @@ class CorrectiveMaintenanceController extends Controller{
             $nuve = "0$nuve";
         }
 
-        $filePath = 'C:\inetpub\wwwroot\sam\public_files\\';
+        $filePath = $this->functionsController->getBasePath() .'\public_files\\';
         $fileName = "$line-$como-$cldo-$fecr-$nuse=$nuve=$noar.$exte";
 
         $dompdf = new Dompdf();
@@ -5689,7 +5689,7 @@ class CorrectiveMaintenanceController extends Controller{
         file_put_contents($tempFile, $output);
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        $ubic = "C:\inetpub\wwwroot\sam\storage\app\\" . $ubic;
+        $ubic = $this->functionsController->getBasePath() ."\sam\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$idUser]);
         unlink($tempFile);

+ 0 - 2
sistema-mantenimiento-back/app/Http/Controllers/DocumentManagementController.php

@@ -1485,11 +1485,9 @@ class DocumentManagementController extends Controller{
             copy($file->AFAL_UBIC, $publicUbi);
         }
 
-        // $apiURI = 'http://192.168.100.105:8000/';
         $apiURI = $this->functionsController->getApiURI();
 
         $publicUbiStr = str_replace('C:\inetpub\wwwroot\\', $apiURI, $publicUbi);
-        // $publicUbiStr = str_replace('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public\\', $apiURI, $publicUbi);
         $publicUbiStr = str_replace('\\', '/', $publicUbiStr);
 
         $arrResponse = [

+ 6 - 10
sistema-mantenimiento-back/app/Http/Controllers/EquipmentManagementController.php

@@ -35,11 +35,7 @@ class EquipmentManagementController extends Controller{
         $this->responseController = new ResponseController();
         $this->encryptionController = new EncryptionController();
         $this->functionsController = new FunctionsController();
-        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->templatesUbic = $this->functionsController->getBasePath() . "\storage\app\public\pdf_templates\\01_05_GEEQ\\";
         $this->documentManagementController = new DocumentManagementController();
 
         $this->pccValidElements = [
@@ -5792,7 +5788,7 @@ class EquipmentManagementController extends Controller{
             }
 
             if($levelIndex == 1){
-                $logo = file_get_contents("C:\inetpub\wwwroot\sam\storage\app\public\global_resources\sam-short-logo.png");
+                $logo = file_get_contents($this->functionsController->getBasePath() ."\storage\app\public\global_resources\sam-short-logo.png");
                 $logoStr = "data:image/svg+xml;base64," . base64_encode($logo);
                 $tableBody .= "
                     <tr>
@@ -5929,7 +5925,7 @@ class EquipmentManagementController extends Controller{
             $nuve = "0$nuve";
         }
 
-        $filePath = 'C:\inetpub\wwwroot\sam\public_files\\';
+        $filePath = $this->functionsController->getBasePath() . '\public_files\\';
         $fileName = "$line-$como-$cldo-$fecr-$nuse=$nuve=$noar.$exte";
 
         $dompdf = new Dompdf();
@@ -5947,7 +5943,7 @@ class EquipmentManagementController extends Controller{
         file_put_contents($tempFile, $output);
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        $ubic = "C:\inetpub\wwwroot\sam\storage\app\\" . $ubic;
+        $ubic = $this->functionsController->getBasePath() ."\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$idUser]);
         unlink($tempFile);
@@ -6168,7 +6164,7 @@ class EquipmentManagementController extends Controller{
         }
 
         $line = $form['linea'] < 10 ? "0$form[linea]" : "$form[linea]";
-        $filePath = 'C:\inetpub\wwwroot\sam\public_files\\';
+        $filePath = $this->functionsController->getBasePath() .'\public_files\\';
         $fileName = "$line-$como-$cldo-$fecr-$nuse=$nuve=$noar.$exte";
         
         $tempFile = $filePath . $fileName;
@@ -6186,7 +6182,7 @@ class EquipmentManagementController extends Controller{
         $writer->save($tempFile);
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        $ubic = "C:\inetpub\wwwroot\sam\storage\app\\" . $ubic;
+        $ubic = $this->functionsController->getBasePath() ."\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$idUser]);
         unlink($tempFile);

+ 8 - 21
sistema-mantenimiento-back/app/Http/Controllers/FailureAnalysisController.php

@@ -1127,12 +1127,8 @@ class FailureAnalysisController extends Controller
         $noar = 'ficha_de_falla_'.$arrFailureLog['NUMERO_FALLA'];
         $exte = 'xlsx';
 
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $filePath = 'C:/ITTEC/SAM/Dev/SistemaMantenimiento/sistema-mantenimiento-back/public/public_files/';    // API JEAN
-        } else {
-            $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';     // API QA
-        }
-        
+        $filePath = $this->functionsController->getBasePath() .'/public/public_files/';    // API JEAN
+
         $fileName = $nuli.'-'.$como.'-'.$cldo.'-'.$fecr.'-'.$nuse.'='.$nuve.'='.$noar.'.'.$exte;
 
         $tempFile = $filePath.$fileName;
@@ -1165,11 +1161,8 @@ class FailureAnalysisController extends Controller
 
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
-        } else {
-            $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
-        }
+        $ubic = $this->functionsController->getBasePath() . "\storage\app\\" . $ubic;
+        
         $tama = filesize($ubic);
         $usac = json_encode([$user]);
 
@@ -1440,11 +1433,8 @@ class FailureAnalysisController extends Controller
         $exte = 'pdf';        
         
         
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $filePath = 'C:/ITTEC/SAM/Dev/SistemaMantenimiento/sistema-mantenimiento-back/public/public_files/';    // API JEAN
-        } else {
-            $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';     // API QA
-        }
+        $filePath = $this->functionsController->getBasePath() . '/public/public_files/';    // API JEAN
+        
 
         $fileName = $nuli.'-'.$como.'-'.$cldo.'-'.$fecr.'-'.$nuse.'='.$nuve.'='.$noar.'.'.$exte;
         
@@ -1461,11 +1451,8 @@ class FailureAnalysisController extends Controller
         $ubic = Storage::putFile('files', new File($tempFile));
 
         $ubic = str_replace("/", "\\", $ubic);
-        if ($_SERVER['SERVER_NAME'] === '192.168.100.105') {
-            $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
-        } else {
-            $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
-        }
+        $ubic = $this->functionsController->getBasePath() . "\storage\app\\" . $ubic;
+        
         $tama = filesize($ubic);
         $usac = json_encode([$user]);
 

+ 4 - 0
sistema-mantenimiento-back/app/Http/Controllers/FunctionsController.php

@@ -328,6 +328,10 @@ class FunctionsController extends Controller{
         return "http://git.ittec.mx/";
     }
 
+    public function getBasePath(): string {
+        return "C:\SistemaMantenimiento\sistema-mantenimiento-back";
+    }
+
     public function validPhoneNumber(string $number) : bool {
         if(intval($number) <= 0) return false;
 

+ 11 - 11
sistema-mantenimiento-back/app/Http/Controllers/PreventiveMaintenanceController.php

@@ -27,7 +27,7 @@ class PreventiveMaintenanceController extends Controller{
         $this->responseController = new ResponseController();
         $this->encryptionController = new EncryptionController();
         $this->functionsController = new FunctionsController();
-        $this->templatesUbic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\public\pdf_templates\\01_03_GMPR\\";
+        $this->templatesUbic = $this->functionsController->getBasePath() ."\storage\app\public\pdf_templates\\01_03_GMPR\\";
         $this->documentManagementController = new DocumentManagementController();
     }
 
@@ -3222,7 +3222,7 @@ class PreventiveMaintenanceController extends Controller{
         ";
 
         foreach($content as $item){
-            $imgContent = file_get_contents("C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\files\\$item[icon].png");
+            $imgContent = file_get_contents($this->functionsController->getBasePath() . "\storage\app\\files\\$item[icon].png");
             $imgB64 = "data:image/png;base64, " . base64_encode($imgContent);
             
             $html .= "
@@ -3266,7 +3266,7 @@ class PreventiveMaintenanceController extends Controller{
             </body>
         </html>";
 
-        $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';
+        $filePath = $this->functionsController->getBasePath() .'\public_files\\';
         $noar = "simulacion_orden_$idOrder";
         $exte = "pdf";
 
@@ -3324,7 +3324,7 @@ class PreventiveMaintenanceController extends Controller{
         file_put_contents($tempFile, $output);
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
+        $ubic = $this->functionsController->getBasePath() ."\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$idUser]);
         unlink($tempFile);
@@ -3644,7 +3644,7 @@ class PreventiveMaintenanceController extends Controller{
         </html>
         ";
 
-        $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';
+        $filePath = $this->functionsController->getBasePath() .'\public_files\\';
         $noar = "detalles_orden_$idOrder";
         $exte = "pdf";
 
@@ -3702,7 +3702,7 @@ class PreventiveMaintenanceController extends Controller{
         file_put_contents($tempFile, $output);
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
+        $ubic = $this->functionsController->getBasePath() ."\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$idUser]);
         unlink($tempFile);
@@ -3789,7 +3789,7 @@ class PreventiveMaintenanceController extends Controller{
         }
 
         $html = file_get_contents($this->templatesUbic . "01-GMPR-PL-010101-000003=01=PDF_PLAN_MANTENIMIENTO.html");
-        $logo = file_get_contents("C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\public\global_resources\sam-short-logo.png");
+        $logo = file_get_contents($this->functionsController->getBasePath() ."\storage\app\public\global_resources\sam-short-logo.png");
         $logoStr = "data:image/svg+xml;base64," . base64_encode($logo);
 
         $html = str_replace("%stcImage%", $logoStr, $html);
@@ -3920,7 +3920,7 @@ class PreventiveMaintenanceController extends Controller{
             $nuve = "0$nuve";
         }
 
-        $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';
+        $filePath = $this->functionsController->getBasePath() .'\public_files\\';
         $fileName = "$line-$como-$cldo-$fecr-$nuse=$nuve=$noar.$exte";
 
         $dompdf = new Dompdf();
@@ -3938,7 +3938,7 @@ class PreventiveMaintenanceController extends Controller{
         file_put_contents($tempFile, $output);
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
+        $ubic = $this->functionsController->getBasePath() ."\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$idUser]);
         unlink($tempFile);
@@ -4299,7 +4299,7 @@ class PreventiveMaintenanceController extends Controller{
         }
 
         $line = $line < 10 ? "0$line" : "$line";
-        $filePath = 'C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\public_files\\';
+        $filePath = $this->functionsController->getBasePath() .'\public_files\\';
         $fileName = "$line-$como-$cldo-$fecr-$nuse=$nuve=$noar.$exte";
         
         $tempFile = $filePath . $fileName;
@@ -4332,7 +4332,7 @@ class PreventiveMaintenanceController extends Controller{
         $writer->save($tempFile);
         $ubic = Storage::putFile('files', new File($tempFile));
         $ubic = str_replace("/", "\\", $ubic);
-        $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
+        $ubic = $this->functionsController->getBasePath() ."\storage\app\\" . $ubic;
         $tama = filesize($ubic);
         $usac = json_encode([$idUser]);
         unlink($tempFile);

+ 31 - 31
sistema-mantenimiento-back/app/Http/Controllers/SystemAdministratorController.php

@@ -613,7 +613,7 @@ class SystemAdministratorController extends Controller{
             "FECHA" => $now->timestamp
         ];
         
-        copy($catalogue->AFAL_UBIC, 'C:\\ITTEC\\SAM\\Dev\\SistemaMantenimiento\\sistema-mantenimiento-back\\public_files\\' . $id);
+        copy($catalogue->AFAL_UBIC, $this->functionsController->getBasePath() . '/public_files/' . $id);
 
         $actions = DB::getQueryLog();
         $name = $this->functionsController->joinName($usr->USUA_NOMB, $usr->USUA_APPA, $usr->USUA_APMA);
@@ -1370,12 +1370,12 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la petición no existe.', [], 404);
         }
 
-        $filePoliticsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\security-politics.json');
+        $filePoliticsExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\security-politics.json');
         if(!$filePoliticsExists){
             return $this->responseController->makeResponse(true, 'El archivo de politicas de seguridad no fue encontrado.', [], 500);
         }
 
-        $politicsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\security-politics.json');
+        $politicsStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\security-politics.json');
         $politicsArr = json_decode($politicsStr, true);
         $passwordFormat = $politicsArr['password_format'];
         $formatBKP = $politicsStr;
@@ -1390,7 +1390,7 @@ class SystemAdministratorController extends Controller{
 
         $politicsArr['password_format'] = $passwordFormat;
         $finalStr = json_encode($politicsArr); 
-        file_put_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\security-politics.json', $finalStr);
+        file_put_contents($this->functionsController->getBasePath() .'\storage\app\files\security-politics.json', $finalStr);
 
         $now = $this->functionsController->now();
         $nowStr = $now->toDateTimeString();
@@ -1500,12 +1500,12 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la petición no existe.', [], 404);
         }
 
-        $filePoliticsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\security-politics.json');
+        $filePoliticsExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\security-politics.json');
         if(!$filePoliticsExists){
             return $this->responseController->makeResponse(true, 'El archivo de politicas de seguridad no fue encontrado.', [], 500);
         }
 
-        $politicsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\security-politics.json');
+        $politicsStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\security-politics.json');
         $politicsArr = json_decode($politicsStr, true);
         $sessionsDuration = $politicsArr['sessions_duration'];
         $formatBKP = $politicsStr;
@@ -1517,7 +1517,7 @@ class SystemAdministratorController extends Controller{
 
         $politicsArr['sessions_duration'] = $sessionsDuration;
         $finalStr = json_encode($politicsArr); 
-        file_put_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\security-politics.json', $finalStr);
+        file_put_contents($this->functionsController->getBasePath() .'\storage\app\files\security-politics.json', $finalStr);
 
         $now = $this->functionsController->now();
         $nowStr = $now->toDateTimeString();
@@ -1624,18 +1624,18 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la petición no existe.', [], 404);
         }
 
-        $filePoliticsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\security-politics.json');
+        $filePoliticsExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\security-politics.json');
         if(!$filePoliticsExists){
             return $this->responseController->makeResponse(true, 'El archivo de politicas de seguridad no fue encontrado.', [], 500);
         }
 
-        $politicsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\security-politics.json');
+        $politicsStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\security-politics.json');
         $politicsArr = json_decode($politicsStr, true);
         $formatBKP = $politicsStr;
         
         $politicsArr['active_sessions_number'] = intval($info['sessions']);
         $finalStr = json_encode($politicsArr); 
-        file_put_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\security-politics.json', $finalStr);
+        file_put_contents($this->functionsController->getBasePath() .'\storage\app\files\security-politics.json', $finalStr);
 
         $now = $this->functionsController->now();
         $nowStr = $now->toDateTimeString();
@@ -1699,12 +1699,12 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la petición no existe.', [], 404);
         }
 
-        $maintenanceModeExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\maintenance_mode.json');
+        $maintenanceModeExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\maintenance_mode.json');
         if(!$maintenanceModeExists){
             return $this->responseController->makeResponse(true, 'El archivo de mantenimiento no fue encontrado.', [], 500);
         }
         
-        $maintenanceStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\maintenance_mode.json');
+        $maintenanceStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\maintenance_mode.json');
         $maintenanceArr = json_decode($maintenanceStr, true);
 
         if($maintenanceArr['activated']){
@@ -1723,7 +1723,7 @@ class SystemAdministratorController extends Controller{
         $maintenanceArr['activated'] = true;
         $maintenanceArr['last_activation_id'] = $idMant;
         $finalStr = json_encode($maintenanceArr);
-        file_put_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\maintenance_mode.json', $finalStr);
+        file_put_contents( $this->functionsController->getBasePath() . '\storage\app\files\maintenance_mode.json', $finalStr);
 
         $actions = DB::getQueryLog();
         $name = $this->functionsController->joinName($usr->USUA_NOMB, $usr->USUA_APPA, $usr->USUA_APMA);
@@ -1777,12 +1777,12 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la petición no existe.', [], 404);
         }
 
-        $maintenanceModeExists = file_exists('C:\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\maintenance_mode.json');
+        $maintenanceModeExists = file_exists($this->functionsController->getBasePath() . '\storage\app\files\maintenance_mode.json');
         if(!$maintenanceModeExists){
             return $this->responseController->makeResponse(true, 'El archivo de mantenimiento no fue encontrado.', [], 500);
         }
 
-        $maintenanceStr = file_get_contents('C:\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\maintenance_mode.json');
+        $maintenanceStr = file_get_contents($this->functionsController->getBasePath() . '\storage\app\files\maintenance_mode.json');
         $maintenanceArr = json_decode($maintenanceStr, true);
 
         if(!$maintenanceArr['activated']){
@@ -1797,7 +1797,7 @@ class SystemAdministratorController extends Controller{
         if(!is_null($maintenanceDB->HMSA_USDE)){
             $maintenanceArr['activated'] = false;
             $finalStr = json_encode($maintenanceArr);
-            file_put_contents('C:\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\maintenance_mode.json', $finalStr);
+            file_put_contents($this->functionsController->getBasePath() . '\storage\app\files\maintenance_mode.json', $finalStr);
 
             return $this->responseController->makeResponse(true, 'El modo mantenimiento ya fue desactivado en la base de datos.', [], 500);
         }
@@ -1816,7 +1816,7 @@ class SystemAdministratorController extends Controller{
         
         $maintenanceArr['activated'] = false;
         $finalStr = json_encode($maintenanceArr);
-        file_put_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\maintenance_mode.json', $finalStr);
+        file_put_contents($this->functionsController->getBasePath() . '\storage\app\files\maintenance_mode.json', $finalStr);
 
         $actions = DB::getQueryLog();
         $name = $this->functionsController->joinName($usr->USUA_NOMB, $usr->USUA_APPA, $usr->USUA_APMA);
@@ -1944,12 +1944,12 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado', [], 404);
         }
 
-        $maintenanceModeExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\maintenance_mode.json');
+        $maintenanceModeExists = file_exists($this->functionsController->getBasePath() . '\storage\app\files\maintenance_mode.json');
         if(!$maintenanceModeExists){
             return $this->responseController->makeResponse(true, 'El archivo de mantenimiento no fue encontrado.', [], 500);
         }
 
-        $maintenanceStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\maintenance_mode.json');
+        $maintenanceStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\maintenance_mode.json');
         $maintenanceArr = json_decode($maintenanceStr, true);
 
         $now = $this->functionsController->now();
@@ -3148,7 +3148,7 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
         }
 
-        $iconsStr = file_get_contents("C:\\ITTEC\\SAM\\Dev\\SistemaMantenimiento\\sistema-mantenimiento-back\\storage\\app\\files\\icons.json");
+        $iconsStr = file_get_contents($this->functionsController->getBasePath() . '\storage\app\files\icons.json');
         $iconsArr = json_decode($iconsStr, true);
         $icons = $iconsArr['icons'];
 
@@ -3199,12 +3199,12 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado', [], 404);
         }
 
-        $systemParamsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $systemParamsExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         if(!$systemParamsExists){
             return $this->responseController->makeResponse(true, 'El archivo de parámetros del sistema no fue encontrado.', [], 500);
         }
 
-        $paramsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $paramsStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         $paramsArr = json_decode($paramsStr, true);
 
         $now = $this->functionsController->now();
@@ -3262,12 +3262,12 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la petición no existe.', [], 404);
         }
 
-        $systemParamsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $systemParamsExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         if(!$systemParamsExists){
             return $this->responseController->makeResponse(true, 'El archivo de parámetros del sistema no fue encontrado.', [], 500);
         }
 
-        $paramsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $paramsStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         $paramsArr = json_decode($paramsStr, true);
 
         $newPriorities = json_decode($form['priorities'], true);
@@ -3277,7 +3277,7 @@ class SystemAdministratorController extends Controller{
 
         $paramsArr['order_priorities'] = $newPriorities;
         $paramsStr = json_encode($paramsArr);
-        file_put_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json', $paramsStr);
+        file_put_contents($this->functionsController->getBasePath() .'\storage\app\files\system-params.json', $paramsStr);
 
         $now = $this->functionsController->now();
         $nowStr = $now->toDateTimeString();
@@ -3316,12 +3316,12 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado', [], 404);
         }
 
-        $systemParamsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $systemParamsExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         if(!$systemParamsExists){
             return $this->responseController->makeResponse(true, 'El archivo de parámetros del sistema no fue encontrado.', [], 500);
         }
 
-        $paramsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $paramsStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         $paramsArr = json_decode($paramsStr, true);
 
         $now = $this->functionsController->now();
@@ -3379,12 +3379,12 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El usuario que realizó la petición no existe.', [], 404);
         }
 
-        $systemParamsExists = file_exists('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $systemParamsExists = file_exists($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         if(!$systemParamsExists){
             return $this->responseController->makeResponse(true, 'El archivo de parámetros del sistema no fue encontrado.', [], 500);
         }
 
-        $paramsStr = file_get_contents('C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\files\system-params.json');
+        $paramsStr = file_get_contents($this->functionsController->getBasePath() .'\storage\app\files\system-params.json');
         $paramsArr = json_decode($paramsStr, true);
         
         $actualImage = $paramsArr["login_params"]["login_$form[tipo]"];
@@ -3403,7 +3403,7 @@ class SystemAdministratorController extends Controller{
             return $this->responseController->makeResponse(true, 'El archivo de la imagen enviada no existe.', [], 500);
         }
 
-        $ubiImgAct = "C:\\ITTEC\\SAM\\Dev\\SistemaMantenimiento\\sistema-mantenimiento-back\\public\\assets\\$actualImage";
+        $ubiImgAct = $this->functionsController->getBasePath() . '\public\assets\$actualImage';
         if(!file_exists($ubiImgAct)){
             return $this->responseController->makeResponse(true, 'La imagen actual no existe.', [], 500);
         }
@@ -3411,7 +3411,7 @@ class SystemAdministratorController extends Controller{
         $now = $this->functionsController->now();
         $timestamp = $now->timestamp;
 
-        rename($ubiImgAct, "C:\\ITTEC\\SAM\\Dev\\SistemaMantenimiento\\sistema-mantenimiento-back\\public\\assets\\UPDATED_$timestamp.png");
+        rename($ubiImgAct, $this->functionsController->getBasePath() . '\public\assets\UPDATED_$timestamp.png');
         copy($ubiImgTmp, $ubiImgAct);
 
         $nowStr = $now->toDateTimeString();