|
@@ -8,46 +8,49 @@ use Illuminate\Support\Facades\Validator;
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
|
|
|
-class DocumentManagementController extends Controller{
|
|
|
|
|
|
|
+class DocumentManagementController extends Controller
|
|
|
|
|
+{
|
|
|
private $responseController;
|
|
private $responseController;
|
|
|
private $encryptionController;
|
|
private $encryptionController;
|
|
|
private $functionsController;
|
|
private $functionsController;
|
|
|
|
|
|
|
|
- public function __construct(){
|
|
|
|
|
|
|
+ public function __construct()
|
|
|
|
|
+ {
|
|
|
$this->responseController = new ResponseController();
|
|
$this->responseController = new ResponseController();
|
|
|
$this->encryptionController = new EncryptionController();
|
|
$this->encryptionController = new EncryptionController();
|
|
|
$this->functionsController = new FunctionsController();
|
|
$this->functionsController = new FunctionsController();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function downloadFile($token, $idUser, $line){
|
|
|
|
|
|
|
+ public function downloadFile($token, $idUser, $line)
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
$tokenInfo = DB::table('S002V01TTODE')->where([
|
|
$tokenInfo = DB::table('S002V01TTODE')->where([
|
|
|
['TODE_NULI', '=', $line],
|
|
['TODE_NULI', '=', $line],
|
|
|
['TODE_TOKE', '=', $token]
|
|
['TODE_TOKE', '=', $token]
|
|
|
])->first();
|
|
])->first();
|
|
|
|
|
|
|
|
-/* if(is_null($tokenInfo)){
|
|
|
|
|
|
|
+ if (is_null($tokenInfo)) {
|
|
|
return $this->responseController->makeResponse(true, 'El token de descarga no existe.', [], 404);
|
|
return $this->responseController->makeResponse(true, 'El token de descarga no existe.', [], 404);
|
|
|
- }else if($tokenInfo->TODE_ESTA != 'Activo'){
|
|
|
|
|
|
|
+ } else if ($tokenInfo->TODE_ESTA != 'Activo') {
|
|
|
return $this->responseController->makeResponse(true, 'El token de descarga ya fue utilizado.', [], 401);
|
|
return $this->responseController->makeResponse(true, 'El token de descarga ya fue utilizado.', [], 401);
|
|
|
- } */
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$token = $this->encryptionController->shortDec($token);
|
|
$token = $this->encryptionController->shortDec($token);
|
|
|
- if(!$token){
|
|
|
|
|
|
|
+ if (!$token) {
|
|
|
return $this->responseController->makeResponse(true, 'El token de descarga no está encriptado correctamente.', [], 400);
|
|
return $this->responseController->makeResponse(true, 'El token de descarga no está encriptado correctamente.', [], 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$tokenArr = explode("|", $token);
|
|
$tokenArr = explode("|", $token);
|
|
|
- if(count($tokenArr) != 3){
|
|
|
|
|
|
|
+ if (count($tokenArr) != 3) {
|
|
|
return $this->responseController->makeResponse(true, 'Estructura de token inválida.', [], 401);
|
|
return $this->responseController->makeResponse(true, 'Estructura de token inválida.', [], 401);
|
|
|
- }else if(intval($tokenArr[1]) != $tokenInfo->TODE_LLAL){
|
|
|
|
|
|
|
+ } else if (intval($tokenArr[1]) != $tokenInfo->TODE_LLAL) {
|
|
|
return $this->responseController->makeResponse(true, 'Token inválido.', [], 401);
|
|
return $this->responseController->makeResponse(true, 'Token inválido.', [], 401);
|
|
|
- }else if($tokenArr[2] != 'syp'){
|
|
|
|
|
|
|
+ } else if ($tokenArr[2] != 'syp') {
|
|
|
return $this->responseController->makeResponse(true, 'Token inválido.', [], 401);
|
|
return $this->responseController->makeResponse(true, 'Token inválido.', [], 401);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$idUser = $this->encryptionController->shortDec($idUser);
|
|
$idUser = $this->encryptionController->shortDec($idUser);
|
|
|
- if(!$idUser){
|
|
|
|
|
|
|
+ if (!$idUser) {
|
|
|
return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
|
|
return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -56,7 +59,7 @@ class DocumentManagementController extends Controller{
|
|
|
['USUA_NULI', '=', $line]
|
|
['USUA_NULI', '=', $line]
|
|
|
])->first();
|
|
])->first();
|
|
|
|
|
|
|
|
- if(is_null($usr)){
|
|
|
|
|
|
|
+ if (is_null($usr)) {
|
|
|
return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
|
|
return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -83,7 +86,7 @@ class DocumentManagementController extends Controller{
|
|
|
'TODE_USDE' => $idUser,
|
|
'TODE_USDE' => $idUser,
|
|
|
'TODE_FEDE' => $nowStr
|
|
'TODE_FEDE' => $nowStr
|
|
|
]);
|
|
]);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$file = DB::table('S002V01TAFAL')->where([
|
|
$file = DB::table('S002V01TAFAL')->where([
|
|
|
['AFAL_NULI', '=', $nuli],
|
|
['AFAL_NULI', '=', $nuli],
|
|
|
['AFAL_COMO', '=', $como],
|
|
['AFAL_COMO', '=', $como],
|
|
@@ -97,22 +100,23 @@ class DocumentManagementController extends Controller{
|
|
|
|
|
|
|
|
$aux = DB::getQueryLog();
|
|
$aux = DB::getQueryLog();
|
|
|
|
|
|
|
|
- if(is_null($file)){
|
|
|
|
|
|
|
+ if (is_null($file)) {
|
|
|
return $this->responseController->makeResponse(true, 'El archivo solicitado no existe.', [], 404);
|
|
return $this->responseController->makeResponse(true, 'El archivo solicitado no existe.', [], 404);
|
|
|
}
|
|
}
|
|
|
return response()->download($file->AFAL_UBIC);
|
|
return response()->download($file->AFAL_UBIC);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getDownloadToken($idFile, $idUser, $line){
|
|
|
|
|
|
|
+ public function getDownloadToken($idFile, $idUser, $line)
|
|
|
|
|
+ {
|
|
|
DB::enableQueryLog();
|
|
DB::enableQueryLog();
|
|
|
|
|
|
|
|
$idFile = $this->encryptionController->shortDec($idFile);
|
|
$idFile = $this->encryptionController->shortDec($idFile);
|
|
|
- if(!$idFile){
|
|
|
|
|
|
|
+ if (!$idFile) {
|
|
|
return $this->responseController->makeResponse(true, 'El ID del archivo requerido no está encriptado correctamente.', [], 400);
|
|
return $this->responseController->makeResponse(true, 'El ID del archivo requerido no está encriptado correctamente.', [], 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$idUser = $this->encryptionController->shortDec($idUser);
|
|
$idUser = $this->encryptionController->shortDec($idUser);
|
|
|
- if(!$idUser){
|
|
|
|
|
|
|
+ if (!$idUser) {
|
|
|
return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
|
|
return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -121,7 +125,7 @@ class DocumentManagementController extends Controller{
|
|
|
['USUA_NULI', '=', $line]
|
|
['USUA_NULI', '=', $line]
|
|
|
])->first();
|
|
])->first();
|
|
|
|
|
|
|
|
- if(is_null($usr)){
|
|
|
|
|
|
|
+ if (is_null($usr)) {
|
|
|
return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
|
|
return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -137,7 +141,7 @@ class DocumentManagementController extends Controller{
|
|
|
$nuve = $codiArr[1];
|
|
$nuve = $codiArr[1];
|
|
|
$noar = $suffArr[0];
|
|
$noar = $suffArr[0];
|
|
|
$exte = $suffArr[1];
|
|
$exte = $suffArr[1];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$file = DB::table('S002V01TAFAL')->where([
|
|
$file = DB::table('S002V01TAFAL')->where([
|
|
|
['AFAL_NULI', '=', $nuli],
|
|
['AFAL_NULI', '=', $nuli],
|
|
|
['AFAL_COMO', '=', $como],
|
|
['AFAL_COMO', '=', $como],
|
|
@@ -150,7 +154,7 @@ class DocumentManagementController extends Controller{
|
|
|
])->first();
|
|
])->first();
|
|
|
|
|
|
|
|
$aux = DB::getQueryLog();
|
|
$aux = DB::getQueryLog();
|
|
|
- if(is_null($file)){
|
|
|
|
|
|
|
+ if (is_null($file)) {
|
|
|
return $this->responseController->makeResponse(true, 'El archivo solicitado no existe.', [], 404);
|
|
return $this->responseController->makeResponse(true, 'El archivo solicitado no existe.', [], 404);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -175,16 +179,17 @@ class DocumentManagementController extends Controller{
|
|
|
return $this->responseController->makeResponse(false, 'EXITO', ['TOKEN' => $token]);
|
|
return $this->responseController->makeResponse(false, 'EXITO', ['TOKEN' => $token]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getFileInfo($id, $idUser, $line){
|
|
|
|
|
|
|
+ public function getFileInfo($id, $idUser, $line)
|
|
|
|
|
+ {
|
|
|
DB::enableQueryLog();
|
|
DB::enableQueryLog();
|
|
|
|
|
|
|
|
$id = $this->encryptionController->shortDec($id);
|
|
$id = $this->encryptionController->shortDec($id);
|
|
|
- if(!$id){
|
|
|
|
|
|
|
+ if (!$id) {
|
|
|
return $this->responseController->makeResponse(true, 'El ID del archivo requerido no está encriptado correctamente.', [], 400);
|
|
return $this->responseController->makeResponse(true, 'El ID del archivo requerido no está encriptado correctamente.', [], 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$idUser = $this->encryptionController->shortDec($idUser);
|
|
$idUser = $this->encryptionController->shortDec($idUser);
|
|
|
- if(!$idUser){
|
|
|
|
|
|
|
+ if (!$idUser) {
|
|
|
return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
|
|
return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la petición no está encriptado correctamente.', [], 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -193,7 +198,7 @@ class DocumentManagementController extends Controller{
|
|
|
['USUA_NULI', '=', $line]
|
|
['USUA_NULI', '=', $line]
|
|
|
])->first();
|
|
])->first();
|
|
|
|
|
|
|
|
- if(is_null($usr)){
|
|
|
|
|
|
|
+ if (is_null($usr)) {
|
|
|
return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
|
|
return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado.', [], 404);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -222,9 +227,9 @@ class DocumentManagementController extends Controller{
|
|
|
['AFAL_NUVE', '=', $nuve],
|
|
['AFAL_NUVE', '=', $nuve],
|
|
|
])->first();
|
|
])->first();
|
|
|
|
|
|
|
|
- if(is_null($fileInfo)){
|
|
|
|
|
|
|
+ if (is_null($fileInfo)) {
|
|
|
return $this->responseController->makeResponse(true, 'El archivo solicitado no está registrado.', [], 404);
|
|
return $this->responseController->makeResponse(true, 'El archivo solicitado no está registrado.', [], 404);
|
|
|
- }else if($fileInfo->ESTADO != 'Activo'){
|
|
|
|
|
|
|
+ } else if ($fileInfo->ESTADO != 'Activo') {
|
|
|
return $this->responseController->makeResponse(true, 'El archivo solicitado no está disponible.', [], 404);
|
|
return $this->responseController->makeResponse(true, 'El archivo solicitado no está disponible.', [], 404);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -262,15 +267,16 @@ class DocumentManagementController extends Controller{
|
|
|
return $this->responseController->makeresponse(false, "EXITO", $documents);
|
|
return $this->responseController->makeresponse(false, "EXITO", $documents);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getInfoDocument($idUser, $line, $idDocument){
|
|
|
|
|
|
|
+ public function getInfoDocument($idUser, $line, $idDocument)
|
|
|
|
|
+ {
|
|
|
DB::enableQueryLog();
|
|
DB::enableQueryLog();
|
|
|
$idUser = $this->encryptionController->shortDec($idUser);
|
|
$idUser = $this->encryptionController->shortDec($idUser);
|
|
|
- if(!$idUser){
|
|
|
|
|
|
|
+ if (!$idUser) {
|
|
|
return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la solicitud no está encriptado correctamente', [], 400);
|
|
return $this->responseController->makeResponse(true, 'El ID del usuario que realizó la solicitud no está encriptado correctamente', [], 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$idDocument = $this->encryptionController->shortDec($idDocument);
|
|
$idDocument = $this->encryptionController->shortDec($idDocument);
|
|
|
- if(!$idDocument){
|
|
|
|
|
|
|
+ if (!$idDocument) {
|
|
|
return $this->responseController->makeResponse(true, 'El ID del documento no está encriptado correctamente', [], 400);
|
|
return $this->responseController->makeResponse(true, 'El ID del documento no está encriptado correctamente', [], 400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -282,4 +288,195 @@ class DocumentManagementController extends Controller{
|
|
|
//$this->functionsController->registerActivity($actions, $idUser, $nowStr, $line);
|
|
//$this->functionsController->registerActivity($actions, $idUser, $nowStr, $line);
|
|
|
return $this->responseController->makeresponse(false, "EXITO", $document);
|
|
return $this->responseController->makeresponse(false, "EXITO", $document);
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public function moveFinalFile(Request $request)
|
|
|
|
|
+ {
|
|
|
|
|
+ DB::enableQueryLog();
|
|
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
|
|
+ 'id_user' => 'required|string',
|
|
|
|
|
+ 'linea' => 'required|integer',
|
|
|
|
|
+ 'audiencia' => 'required|json',
|
|
|
|
|
+ 'archivos' => 'required|json',
|
|
|
|
|
+ 'cldo' => 'required|string',
|
|
|
|
|
+ ''
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ if($validator->fails()){
|
|
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
|
|
+ true,
|
|
|
|
|
+ "Se encontraron uno o más errores.",
|
|
|
|
|
+ $this->responseController->makeErrors(
|
|
|
|
|
+ $validator->errors()->messages()
|
|
|
|
|
+ ),
|
|
|
|
|
+ 401
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $advice = $request->all();
|
|
|
|
|
+ $idUser = $this->encryptionController->decrypt($advice['id_user']);
|
|
|
|
|
+ if(!$idUser){
|
|
|
|
|
+ return $this->responseController->makeResponse(true, "El ID del usuario que realizó la petición no fue encriptado correctamente", [], 400);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $usr = DB::table('S002V01TUSUA')->where([
|
|
|
|
|
+ ['USUA_IDUS', '=', $idUser],
|
|
|
|
|
+ ['USUA_NULI', '=', $advice['linea']]
|
|
|
|
|
+ ])->first();
|
|
|
|
|
+
|
|
|
|
|
+ if(is_null($usr)){
|
|
|
|
|
+ return $this->responseController->makeResponse(true, 'El usuario que realizó la consulta no está registrado', [], 404);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $filesArr = json_decode($advice['archivos'], true);
|
|
|
|
|
+ $nowStr = Carbon::now('America/Mexico_city')->toDateTimeString();
|
|
|
|
|
+ $attachedArr = [];
|
|
|
|
|
+ foreach($filesArr as $file){
|
|
|
|
|
+ $idFile = $file['id'];
|
|
|
|
|
+ $idFile = $this->encryptionController->decrypt($idFile);
|
|
|
|
|
+ if(!$idFile){
|
|
|
|
|
+ return $this->responseController->makeResponse(true, "El ID del archivo $file[name] no fue encriptado correctamente", [], 400);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $fileObj = DB::table('S002V01TARTE')->where([
|
|
|
|
|
+ ['ARTE_IDAR', '=', $idFile],
|
|
|
|
|
+ ['ARTE_NULI', '=', $advice['linea']]
|
|
|
|
|
+ ])->first();
|
|
|
|
|
+
|
|
|
|
|
+ if(is_null($fileObj)){
|
|
|
|
|
+ return $this->responseController->makeResponse(true, "El ID del archivo $file[name] no existe", [], 404);
|
|
|
|
|
+ }else if($fileObj->ARTE_ESTA == 'Eliminado'){
|
|
|
|
|
+ return $this->responseController->makeResponse(true, "El archivo $file[name] está eliminado", [], 404);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $fileSaved = $this->moveFinalFile($advice['linea'], 'AV', $fileObj, 'S002V01M01ADSI', 'S002V01F03CRAV', 'S002V01P02CNAV');
|
|
|
|
|
+ if(!$fileSaved[0]){
|
|
|
|
|
+ return $this->responseController->makeResponse(true, "El archivo no pudo guardarse: $fileSaved[1]", [], 500);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $attachedArr[] = $this->encryptionController->encrypt($fileSaved[1]);
|
|
|
|
|
+
|
|
|
|
|
+ DB::table('S002V01TARTE')->where([
|
|
|
|
|
+ ['ARTE_IDAR', '=', $idFile],
|
|
|
|
|
+ ['ARTE_NULI', '=', $advice['linea']],
|
|
|
|
|
+ ])->update([
|
|
|
|
|
+ 'ARTE_ESTA' => 'Eliminado',
|
|
|
|
|
+ 'ARTE_USMO' => $idUser,
|
|
|
|
|
+ 'ARTE_FEMO' => $nowStr
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $ubiTempFile = $file->ARTE_UBTE;
|
|
|
|
|
+ $ubiFileArr = explode('tempFiles', $ubiTempFile);
|
|
|
|
|
+ $ubic = $ubiFileArr[0] . 'files' . $ubiFileArr[1];
|
|
|
|
|
+
|
|
|
|
|
+ $como = substr($module, -4);
|
|
|
|
|
+ $date = Carbon::now('America/Mexico_city')->toDateTimeString();
|
|
|
|
|
+ $dateArr = explode(' ', $date);
|
|
|
|
|
+ $dateStr = $dateArr[0];
|
|
|
|
|
+ $dA = explode('-', $dateStr);
|
|
|
|
|
+ $dA[0] = substr($dA[0], -2);
|
|
|
|
|
+ $fecr = implode('', $dA);
|
|
|
|
|
+
|
|
|
|
|
+ $nameStr = $file->ARTE_NOAR;
|
|
|
|
|
+ $nameArr = explode('.', $nameStr);
|
|
|
|
|
+
|
|
|
|
|
+ $nuve = 0;
|
|
|
|
|
+ $nuse = 0;
|
|
|
|
|
+
|
|
|
|
|
+ $lastSec = DB::table('S002V01TAFAL')->where([
|
|
|
|
|
+ ['AFAL_NULI', '=', $line],
|
|
|
|
|
+ ['AFAL_COMO', '=', $como],
|
|
|
|
|
+ ['AFAL_CLDO', '=', $cldo]
|
|
|
|
|
+ ])->orderBy('AFAL_NUSE', 'desc')->first();
|
|
|
|
|
+
|
|
|
|
|
+ if (is_null($lastSec)) {
|
|
|
|
|
+ $nuse = 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $nuse = $lastSec->AFAL_NUSE + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $lastVersion = DB::table('S002V01TAFAL')->where([
|
|
|
|
|
+ ['AFAL_NULI', '=', $line],
|
|
|
|
|
+ ['AFAL_NOAR', '=', $nameArr[0]],
|
|
|
|
|
+ ['AFAL_EXTE', '=', $nameArr[1]],
|
|
|
|
|
+ ])->orderBy('AFAL_NUVE', 'desc')->first();
|
|
|
|
|
+
|
|
|
|
|
+ if (is_null($lastVersion)) {
|
|
|
|
|
+ $nuve = 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $nuve = $lastVersion->AFAL_NUVE + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($nuve > 99) return [false, 'El archivo llegó al número máximo de versiones'];
|
|
|
|
|
+ if ($nuse > 999999) return [false, 'El archivo llegó al número de secuencia máximo'];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $noar = $nameArr[0];
|
|
|
|
|
+ $exte = $nameArr[1];
|
|
|
|
|
+
|
|
|
|
|
+ if (strlen($noar) > 100) return [false, 'El nombre del archivo tiene una longitud mayor a 100 caracteres'];
|
|
|
|
|
+ $tama = $file->ARTE_TAMA;
|
|
|
|
|
+ $usac = json_encode([$file->ARTE_USRE]);
|
|
|
|
|
+ $usre = $file->ARTE_USRE;
|
|
|
|
|
+ $fere = $file->ARTE_FERE;
|
|
|
|
|
+
|
|
|
|
|
+ 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' => $usre,
|
|
|
|
|
+ 'AFAL_FERE' => $fere
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ if (file_exists($file->ARTE_UBTE)) {
|
|
|
|
|
+ rename($file->ARTE_UBTE, $ubic);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $codigo = "";
|
|
|
|
|
+ if (strlen($line) < 2) {
|
|
|
|
|
+ $codigo .= "0$line-";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $codigo .= "$line-";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $codigo .= "$como-$cldo-$fecr-";
|
|
|
|
|
+ switch (strlen($nuse)) {
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ $codigo .= "00000$nuse";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ $codigo .= "0000$nuse";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ $codigo .= "000$nuse";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 4:
|
|
|
|
|
+ $codigo .= "00$nuse";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 5:
|
|
|
|
|
+ $codigo .= "0$nuse";
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ $codigo .= "$nuse";
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strlen($nuve) < 2) {
|
|
|
|
|
+ $codigo .= "=0$nuve=";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $codigo .= "=$nuve=";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $codigo .= "$noar.$exte";
|
|
|
|
|
+
|
|
|
|
|
+ return [true, $codigo];
|
|
|
|
|
+ }
|
|
|
|
|
+}
|