|
|
@@ -11,11 +11,14 @@ use App\Http\Controllers\ResponseController;
|
|
|
use App\Http\Controllers\EncryptionController;
|
|
|
use App\Http\Controllers\FunctionsController;
|
|
|
use App\Http\Controllers\DocumentManagementController;
|
|
|
+use Illuminate\Support\Facades\Storage;
|
|
|
+use Illuminate\Http\File;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
+use Dompdf\Dompdf;
|
|
|
|
|
|
|
|
|
class ProviderController extends Controller{
|
|
|
@@ -363,7 +366,7 @@ class ProviderController extends Controller{
|
|
|
'PROV_NUIN' => $arrInformationPersonal['INTERIOR'],
|
|
|
'PROV_COPO' => $arrInformationPersonal['CODIGO_POSTAL'],
|
|
|
'PROV_COLO' => $arrInformationPersonal['COLONIA'],
|
|
|
- 'PROV_LOCA' => $arrInformationPersonal['LOCALIDAD'],
|
|
|
+ 'PROV_LOCA' => $arrInformationPersonal['LOCALIDAD'] === 'Sin localidad' ? null : $arrInformationPersonal['LOCALIDAD'],
|
|
|
'PROV_MUNI' => $arrInformationPersonal['MUNICIPIO'],
|
|
|
'PROV_ENTI' => $arrInformationPersonal['ENTIDAD'],
|
|
|
'PROV_PAIS' => $arrInformationPersonal['PAIS'],
|
|
|
@@ -735,7 +738,7 @@ class ProviderController extends Controller{
|
|
|
'PESU_NUIN' => $arrInformationPersonal['INTERIOR'],
|
|
|
'PESU_COLO' => $arrInformationPersonal['COLONIA'],
|
|
|
'PESU_CIUD' => $arrInformationPersonal['MUNICIPIO'],
|
|
|
- 'PESU_LOCA' => $arrInformationPersonal['LOCALIDAD'],
|
|
|
+ 'PESU_LOCA' => $arrInformationPersonal['LOCALIDAD'] === 'Sin localidad' ? null : $arrInformationPersonal['LOCALIDAD'],
|
|
|
'PESU_COPO' => $arrInformationPersonal['CODIGO_POSTAL'],
|
|
|
'PESU_ENFE' => $arrInformationPersonal['ENTIDAD'],
|
|
|
'PESU_IDPA' => $arrInformationPersonal['PAIS'],
|
|
|
@@ -749,30 +752,6 @@ class ProviderController extends Controller{
|
|
|
);
|
|
|
} catch (\Throwable $th) {
|
|
|
DB::rollBack();
|
|
|
- var_dump([
|
|
|
- 'PESU_RASO' => $arrInformationPersonal['RAZON_SOCIAL'],
|
|
|
- 'PESU_REFI' => $arrInformationPersonal['REGIMEN_FISCAL'],
|
|
|
- 'PESU_XRFC' => $arrInformationPersonal['RFC'] != '' ? $arrInformationPersonal['RFC'] : null,
|
|
|
- 'PESU_TIPO' => $arrInformationPersonal['TIPO_CONTRIBUYENTE'],
|
|
|
- 'PESU_CORR' => $arrInformationPersonal['CORREO'],
|
|
|
- 'PESU_EXTR' => $arrInformationPersonal['TIPO'] === 'Nacional' ? 'No' : 'Si',
|
|
|
- 'PESU_TAID' => $arrInformationPersonal['TAXID'] != '' ? $arrInformationPersonal['TAXID'] : null,
|
|
|
- 'PESU_CALL' => $arrInformationPersonal['CALLE'],
|
|
|
- 'PESU_NUEX' => $arrInformationPersonal['EXTERIOR'],
|
|
|
- 'PESU_NUIN' => $arrInformationPersonal['INTERIOR'],
|
|
|
- 'PESU_COLO' => $arrInformationPersonal['COLONIA'],
|
|
|
- 'PESU_CIUD' => $arrInformationPersonal['MUNICIPIO'],
|
|
|
- 'PESU_LOCA' => $arrInformationPersonal['LOCALIDAD'],
|
|
|
- 'PESU_COPO' => $arrInformationPersonal['CODIGO_POSTAL'],
|
|
|
- 'PESU_ENFE' => $arrInformationPersonal['ENTIDAD'],
|
|
|
- 'PESU_IDPA' => $arrInformationPersonal['PAIS'],
|
|
|
- 'PESU_TEL1' => $arrInformationPersonal['TELEFONO1'],
|
|
|
- 'PESU_LAT1' => $arrInformationPersonal['LADA1'],
|
|
|
- 'PESU_TEL2' => $arrInformationPersonal['TELEFONO2'] != '' ? $arrInformationPersonal['TELEFONO2'] : null,
|
|
|
- 'PESU_LAT2' => $arrInformationPersonal['LADA2'] != '' ? $arrInformationPersonal['LADA2'] : null,
|
|
|
- 'PESU_USMO' => $user,
|
|
|
- 'PESU_FEMO' => $currentDate,
|
|
|
- ]);
|
|
|
return $this->responseController->makeResponse(true, "ERR_PROVIDER_MOD030: Ocurrió un error al modificar el subcontratista.", $th->getMessage(), 500);
|
|
|
}
|
|
|
if ( !$updateSubcontract ) {
|
|
|
@@ -880,7 +859,7 @@ class ProviderController extends Controller{
|
|
|
'PROV_NUIN' => $arrInformationPersonal['INTERIOR'] != '' ? $arrInformationPersonal['INTERIOR'] : null,
|
|
|
'PROV_COPO' => $arrInformationPersonal['CODIGO_POSTAL'],
|
|
|
'PROV_COLO' => $arrInformationPersonal['COLONIA'],
|
|
|
- 'PROV_LOCA' => $arrInformationPersonal['LOCALIDAD'],
|
|
|
+ 'PROV_LOCA' => $arrInformationPersonal['LOCALIDAD'] === 'Sin localidad' ? null : $arrInformationPersonal['LOCALIDAD'],
|
|
|
'PROV_MUNI' => $arrInformationPersonal['MUNICIPIO'],
|
|
|
'PROV_ENTI' => $arrInformationPersonal['ENTIDAD'],
|
|
|
'PROV_PAIS' => $arrInformationPersonal['PAIS'],
|
|
|
@@ -1568,7 +1547,7 @@ class ProviderController extends Controller{
|
|
|
|
|
|
}
|
|
|
|
|
|
- public function generateSheetProvider($encProvider, $user, $line) {
|
|
|
+ public function generateSheetProviderXLS($encProvider, $user, $line) {
|
|
|
|
|
|
try {
|
|
|
$idProvider = $this->encController->decrypt($encProvider);
|
|
|
@@ -1582,6 +1561,18 @@ class ProviderController extends Controller{
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ try {
|
|
|
+ $user = $this->encController->decrypt($user);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET001: Ocurrió un error al obtener el usuario.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
$arrProvider = (array) DB::table('S002V01TPROV')
|
|
|
->where('PROV_NUPR', '=', $idProvider)
|
|
|
@@ -1624,14 +1615,13 @@ class ProviderController extends Controller{
|
|
|
'PROV_USMO',
|
|
|
'PROV_FEMO',
|
|
|
'PROV_FEAR',
|
|
|
-
|
|
|
'REFI_CRFI',
|
|
|
'REFI_DRFI',
|
|
|
]);
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET001: Ocurrió un error al obtener la información del proveedor.",
|
|
|
+ "ERR_PROVIDER_SHEET002: Ocurrió un error al obtener la información del proveedor.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
@@ -1640,7 +1630,7 @@ class ProviderController extends Controller{
|
|
|
if ( empty($arrProvider) ) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET002: El proveedor seleccionado no existe.",
|
|
|
+ "ERR_PROVIDER_SHEET003: El proveedor seleccionado no existe.",
|
|
|
[],
|
|
|
500
|
|
|
);
|
|
|
@@ -1649,7 +1639,7 @@ class ProviderController extends Controller{
|
|
|
if ($arrProvider['PROV_ESTA'] !== 'Activo') {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET003: El proveedor seleccionado no se encuentra activo.",
|
|
|
+ "ERR_PROVIDER_SHEET004: El proveedor seleccionado no se encuentra activo.",
|
|
|
[],
|
|
|
500
|
|
|
);
|
|
|
@@ -1669,14 +1659,17 @@ class ProviderController extends Controller{
|
|
|
'PRRE_XRFC',
|
|
|
'PRRE_DIRE',
|
|
|
]);
|
|
|
+
|
|
|
+ $arrReference = json_decode( json_encode($arrReference), true );
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET004: Ocurrió un error al obtener las referencias del proveedor.",
|
|
|
+ "ERR_PROVIDER_SHEET005: Ocurrió un error al obtener las referencias del proveedor.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
try {
|
|
|
$arrContact = DB::table('S002V01TPRCO')
|
|
|
->where('PRCO_NUPR', '=', $idProvider)
|
|
|
@@ -1703,14 +1696,17 @@ class ProviderController extends Controller{
|
|
|
'PRCO_COR2',
|
|
|
'PRCO_OBSE',
|
|
|
]);
|
|
|
+
|
|
|
+ $arrContact = json_decode( json_encode($arrContact), true );
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET005: Ocurrió un error al obtener los contactos del proveedor.",
|
|
|
+ "ERR_PROVIDER_SHEET006: Ocurrió un error al obtener los contactos del proveedor.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
try {
|
|
|
$arrCondition = DB::table('S002V01TPRCN')
|
|
|
->where('PRCN_NUPR', '=', $idProvider)
|
|
|
@@ -1721,10 +1717,11 @@ class ProviderController extends Controller{
|
|
|
'PRCN_TIPO',
|
|
|
'PRCN_INFO',
|
|
|
]);
|
|
|
+ $arrCondition = json_decode( json_encode($arrCondition), true );
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET006: Ocurrió un error al obtener las condiciones del proveedor.",
|
|
|
+ "ERR_PROVIDER_SHEET007: Ocurrió un error al obtener las condiciones del proveedor.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
@@ -1741,10 +1738,11 @@ class ProviderController extends Controller{
|
|
|
'PRCE_DESC',
|
|
|
'PRCE_XURL',
|
|
|
]);
|
|
|
+ $arrCatalog = json_decode( json_encode($arrCatalog), true );
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET007: Ocurrió un error al obtener los catálogos del proveedor.",
|
|
|
+ "ERR_PROVIDER_SHEET008: Ocurrió un error al obtener los catálogos del proveedor.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
@@ -1755,26 +1753,22 @@ class ProviderController extends Controller{
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET008: El proveedor seleccionado no se encuentra activo.",
|
|
|
+ "ERR_PROVIDER_SHEET009: El proveedor seleccionado no se encuentra activo.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- $arrProvider['REFERENCE'] = $arrReference;
|
|
|
- $arrProvider['CONTACT'] = $arrContact;
|
|
|
- $arrProvider['CONDITION'] = $arrCondition;
|
|
|
- $arrProvider['CATALOG'] = $arrCatalog;
|
|
|
- $arrProvider['PROV_MEPA'] = $arrPayment;
|
|
|
|
|
|
$spreadsheet = new Spreadsheet();
|
|
|
$activeWorksheet = $spreadsheet->getActiveSheet()->setTitle($arrProvider['PROV_NUPR']);
|
|
|
|
|
|
+
|
|
|
$headerA1 = 'Número de Proveedor';
|
|
|
- $contentA1 = '#'.$arrProvider['PROV_NUPR'];
|
|
|
+ $contentA1 = $arrProvider['PROV_NUPR'];
|
|
|
$activeWorksheet->setCellValue("A1", $headerA1);
|
|
|
- $activeWorksheet->setCellValue("A2", $contentA1);
|
|
|
- $activeWorksheet->getColumnDimension("A")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("B1", $contentA1);
|
|
|
+ $activeWorksheet->getStyle( "A1" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerB1 = 'Número de Subcontratista';
|
|
|
@@ -1782,31 +1776,31 @@ class ProviderController extends Controller{
|
|
|
if ( $arrProvider['PROV_IDPS'] === null || $arrProvider['PROV_IDPS'] === '' ) {
|
|
|
$contentB1 = 'Sin Subcontratista';
|
|
|
} else {
|
|
|
- $contentB1 = '#' . $arrProvider['PROV_IDPS'];
|
|
|
+ $contentB1 = $arrProvider['PROV_IDPS'];
|
|
|
}
|
|
|
- $activeWorksheet->setCellValue("B1", $headerB1);
|
|
|
+ $activeWorksheet->setCellValue("A2", $headerB1);
|
|
|
$activeWorksheet->setCellValue("B2", $contentB1);
|
|
|
- $activeWorksheet->getColumnDimension("B")->setAutoSize(true);
|
|
|
+ $activeWorksheet->getStyle( "A2" )->getFont()->setBold(true);
|
|
|
|
|
|
$headerC1 = "Nombre Comercial";
|
|
|
$contentC1 = $arrProvider['PROV_NOCO'];
|
|
|
- $activeWorksheet->setCellValue("C1", $headerC1);
|
|
|
- $activeWorksheet->setCellValue("C2", $contentC1);
|
|
|
- $activeWorksheet->getColumnDimension("C")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A3", $headerC1);
|
|
|
+ $activeWorksheet->setCellValue("B3", $contentC1);
|
|
|
+ $activeWorksheet->getStyle( "A3" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerD1 = 'Responsable';
|
|
|
$contentD1 = $arrProvider['PROV_NOMB'].' '.$arrProvider['PROV_APPA'].' '.$arrProvider['PROV_APMA'] === null ? '' : $arrProvider['PROV_APMA'];
|
|
|
- $activeWorksheet->setCellValue("D1", $headerD1);
|
|
|
- $activeWorksheet->setCellValue("D2", $contentD1);
|
|
|
- $activeWorksheet->getColumnDimension("D")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A4", $headerD1);
|
|
|
+ $activeWorksheet->setCellValue("B4", $contentD1);
|
|
|
+ $activeWorksheet->getStyle( "A4" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerE1 = 'Correo electrónico';
|
|
|
$contentE1 = $arrProvider['PROV_CORR'];
|
|
|
- $activeWorksheet->setCellValue("E1", $headerE1);
|
|
|
- $activeWorksheet->setCellValue("E2", $contentE1);
|
|
|
- $activeWorksheet->getColumnDimension("E")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A5", $headerE1);
|
|
|
+ $activeWorksheet->setCellValue("B5", $contentE1);
|
|
|
+ $activeWorksheet->getStyle( "A5" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerF1 = '';
|
|
|
@@ -1821,36 +1815,36 @@ class ProviderController extends Controller{
|
|
|
$headerF1 = 'R.F.C / TAX ID';
|
|
|
$contentF1 = 'Sin contenido';
|
|
|
}
|
|
|
- $activeWorksheet->setCellValue("F1", $headerF1);
|
|
|
- $activeWorksheet->setCellValue("F2", $contentF1);
|
|
|
- $activeWorksheet->getColumnDimension("F")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A6", $headerF1);
|
|
|
+ $activeWorksheet->setCellValue("B6", $contentF1);
|
|
|
+ $activeWorksheet->getStyle( "A6" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerF1 = 'Régimen fiscal';
|
|
|
$contentF1 = $arrProvider['REFI_DRFI'] . ' (' . $arrProvider['REFI_CRFI'] . ')';
|
|
|
- $activeWorksheet->setCellValue("G1", "Régimen Fiscal");
|
|
|
- $activeWorksheet->setCellValue("G2", $contentF1);
|
|
|
- $activeWorksheet->getColumnDimension("G")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A7", "Régimen Fiscal");
|
|
|
+ $activeWorksheet->setCellValue("B7", $contentF1);
|
|
|
+ $activeWorksheet->getStyle( "A7" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerH1 = 'Tipo de ciudadania';
|
|
|
$contentH1 = $arrProvider['PROV_TIPO'];
|
|
|
- $activeWorksheet->setCellValue("H1", $headerH1);
|
|
|
- $activeWorksheet->setCellValue("H2", $contentH1);
|
|
|
- $activeWorksheet->getColumnDimension("H")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A8", $headerH1);
|
|
|
+ $activeWorksheet->setCellValue("B8", $contentH1);
|
|
|
+ $activeWorksheet->getStyle( "A9" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerI1 = 'Tipo de contribuyente';
|
|
|
$contentI1 = $arrProvider['PROV_TICO'];
|
|
|
- $activeWorksheet->setCellValue("I1", $headerI1);
|
|
|
- $activeWorksheet->setCellValue("I2", $contentI1);
|
|
|
- $activeWorksheet->getColumnDimension("I")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A9", $headerI1);
|
|
|
+ $activeWorksheet->setCellValue("B9", $contentI1);
|
|
|
+ $activeWorksheet->getStyle( "A9" )->getFont()->setBold(true);
|
|
|
|
|
|
$headerJ1 = 'Teléfono principal';
|
|
|
$contentJ1 = '('.$arrProvider['PROV_LAD1'] .') '. $arrProvider['PROV_TEL1'];
|
|
|
- $activeWorksheet->setCellValue("J1", $headerJ1);
|
|
|
- $activeWorksheet->setCellValue("J2", $contentJ1);
|
|
|
- $activeWorksheet->getColumnDimension("J")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A10", $headerJ1);
|
|
|
+ $activeWorksheet->setCellValue("B10", $contentJ1);
|
|
|
+ $activeWorksheet->getStyle( "A10" )->getFont()->setBold(true);
|
|
|
|
|
|
$headerK1 = 'Teléfono secundario';
|
|
|
$contentK1 = '';
|
|
|
@@ -1859,9 +1853,9 @@ class ProviderController extends Controller{
|
|
|
} else {
|
|
|
$contentK1 = 'No aplica';
|
|
|
}
|
|
|
- $activeWorksheet->setCellValue("K1", $headerK1);
|
|
|
- $activeWorksheet->setCellValue("K2", $contentK1);
|
|
|
- $activeWorksheet->getColumnDimension("K")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A11", $headerK1);
|
|
|
+ $activeWorksheet->setCellValue("B11", $contentK1);
|
|
|
+ $activeWorksheet->getStyle( "A11" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerL1 = 'Enlace de sitio web';
|
|
|
@@ -1871,219 +1865,1220 @@ class ProviderController extends Controller{
|
|
|
} else {
|
|
|
$contentL1 = 'No aplica';
|
|
|
}
|
|
|
- $activeWorksheet->setCellValue("L1", $headerL1);
|
|
|
- $activeWorksheet->setCellValue("L2", $contentL1);
|
|
|
- $activeWorksheet->getColumnDimension("L")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A12", $headerL1);
|
|
|
+ $activeWorksheet->setCellValue("B12", $contentL1);
|
|
|
+ $activeWorksheet->getStyle( "A12" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerM1 = 'Calle ';
|
|
|
$contentM1 = $arrProvider['PROV_CALL'];
|
|
|
- $activeWorksheet->setCellValue("M1", $headerM1);
|
|
|
- $activeWorksheet->setCellValue("M2", $contentM1);
|
|
|
- $activeWorksheet->getColumnDimension("M")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A13", $headerM1);
|
|
|
+ $activeWorksheet->setCellValue("B13", $contentM1);
|
|
|
+ $activeWorksheet->getStyle( "A13" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerN1 = 'Número exterior';
|
|
|
$contentN1 = $arrProvider['PROV_NUEX'];
|
|
|
- $activeWorksheet->setCellValue("N1", $headerN1);
|
|
|
- $activeWorksheet->setCellValue("N2", $contentN1);
|
|
|
- $activeWorksheet->getColumnDimension("N")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A14", $headerN1);
|
|
|
+ $activeWorksheet->setCellValue("B14", $contentN1);
|
|
|
+ $activeWorksheet->getStyle( "A14" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerO1 = 'Número interior';
|
|
|
$contentO1 = '';
|
|
|
- if ($arrProvider['PROV_NUEX'] !== null && $arrProvider['PROV_NUEX'] !== '') {
|
|
|
- $contentO1 = $arrProvider['PROV_NUEX'];
|
|
|
+ if ($arrProvider['PROV_NUIN'] !== null && $arrProvider['PROV_NUIN'] !== '') {
|
|
|
+ $contentO1 = $arrProvider['PROV_NUIN'];
|
|
|
} else {
|
|
|
$contentO1 = 'No aplica';
|
|
|
}
|
|
|
- $activeWorksheet->setCellValue("O1", $headerO1);
|
|
|
- $activeWorksheet->setCellValue("O2", $contentO1);
|
|
|
- $activeWorksheet->getColumnDimension("O")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A15", $headerO1);
|
|
|
+ $activeWorksheet->setCellValue("B15", $contentO1);
|
|
|
+ $activeWorksheet->getStyle( "A15" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerP1 = 'Código postal';
|
|
|
$contentP1 = $arrProvider['PROV_COPO'];
|
|
|
- $activeWorksheet->setCellValue("P1", $headerP1);
|
|
|
- $activeWorksheet->setCellValue("P2", $contentP1);
|
|
|
- $activeWorksheet->getColumnDimension("P")->setAutoSize(true);
|
|
|
+ $activeWorksheet->setCellValue("A16", $headerP1);
|
|
|
+ $activeWorksheet->setCellValue("B16", $contentP1);
|
|
|
+ $activeWorksheet->getStyle( "A16" )->getFont()->setBold(true);
|
|
|
|
|
|
|
|
|
$headerQ1 = 'Colonia';
|
|
|
+ if ($arrProvider['PROV_PAIS'] === 'MEX') {
|
|
|
+ try {
|
|
|
+ $arrColony = (array) DB::table('S002V01TCOLO')
|
|
|
+ ->where('COLO_NULI', '=', $line)
|
|
|
+ ->where('COLO_COCO', '=', $arrProvider['PROV_COLO'])
|
|
|
+ ->where('COLO_COPO', '=', $arrProvider['PROV_COPO'])
|
|
|
+ ->where('COLO_ESTA', '=', 'Activo')
|
|
|
+ ->first([ 'COLO_COCO', 'COLO_NOCO' ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET010: Ocurrió un error al obtener la información de la colonia.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if ( empty($arrColony) ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET011: No se encontró la colonia asociada al proveedor.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $contentQ1 = $arrColony['COLO_NOCO'] . ' (' . $arrColony['COLO_COCO'] . ')';
|
|
|
+ } else {
|
|
|
+ $contentQ1 = $arrProvider['PROV_COLO'];
|
|
|
+ }
|
|
|
+ $activeWorksheet->setCellValue("A17", $headerQ1);
|
|
|
+ $activeWorksheet->setCellValue("B17", $contentQ1);
|
|
|
+ $activeWorksheet->getStyle( "A17" )->getFont()->setBold(true);
|
|
|
+
|
|
|
+
|
|
|
+ $headerR1 = 'Localidad';
|
|
|
+ $contentR1 = '';
|
|
|
+ if ($arrProvider['PROV_PAIS'] === 'MEX') {
|
|
|
+ if ( !is_null($arrProvider['PROV_LOCA']) && !empty($arrProvider['PROV_LOCA']) ) {
|
|
|
+ try {
|
|
|
+ $arrLocate = (array) DB::table('S002V01TLOCA')
|
|
|
+ ->where('LOCA_NULI', '=', $line)
|
|
|
+ ->where('LOCA_COLO', '=', $arrProvider['PROV_LOCA'])
|
|
|
+ ->where('LOCA_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
+ ->where('LOCA_ESTA', '=', 'Activo')
|
|
|
+ ->first([ 'LOCA_COLO', 'LOCA_NOLO' ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET012: Ocurrió un error al obtener la información de la localidad.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( empty($arrLocate) ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET013: No se encontró la localidad asociada al proveedor.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ $contentR1 = $arrLocate['LOCA_NOLO'] . ' (' . $arrLocate['LOCA_NOLO'] . ')';
|
|
|
+ } else {
|
|
|
+ $contentR1 = 'Sin localidad';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ( !is_null($arrProvider['PROV_LOCA']) && !empty($arrProvider['PROV_LOCA']) ) {
|
|
|
+ $contentR1 = $arrProvider['PROV_LOCA'];
|
|
|
+ } else {
|
|
|
+ $contentR1 = 'Sin localidad';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $activeWorksheet->setCellValue("A18", $headerR1);
|
|
|
+ $activeWorksheet->setCellValue("B18", $contentR1);
|
|
|
+ $activeWorksheet->getColumnDimension("R")->setAutoSize(true);
|
|
|
+ $activeWorksheet->getStyle( "A18" )->getFont()->setBold(true);
|
|
|
+
|
|
|
+
|
|
|
+ $headerS1 = 'Municipio';
|
|
|
+ $contentS1 = '';
|
|
|
+ if ($arrProvider['PROV_PAIS'] === 'MEX') {
|
|
|
+ try {
|
|
|
+ $arrMunicipality = (array) DB::table('S002V01TMUNI')
|
|
|
+ ->where('MUNI_NULI', '=', $line)
|
|
|
+ ->where('MUNI_COMU', '=', $arrProvider['PROV_MUNI'])
|
|
|
+ ->where('MUNI_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
+ ->where('MUNI_ESTA', '=', 'Activo')
|
|
|
+ ->first([ 'MUNI_COMU', 'MUNI_NOMU' ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET014: Ocurrió un error al obtener la información del municipio.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if ( empty($arrMunicipality) ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET015: No se encontró el municipio asociada al proveedor.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $contentS1 = $arrMunicipality['MUNI_NOMU'] . ' (' . $arrMunicipality['MUNI_COMU'] . ')';
|
|
|
+ } else {
|
|
|
+ $contentS1 = $arrProvider['PROV_MUNI'];
|
|
|
+ }
|
|
|
+ $activeWorksheet->setCellValue("A19", $headerS1);
|
|
|
+ $activeWorksheet->setCellValue("B19", $contentS1);
|
|
|
+ $activeWorksheet->getStyle( "A19" )->getFont()->setBold(true);
|
|
|
+
|
|
|
+
|
|
|
+ $headerT1 = 'Entidad Federativa';
|
|
|
+ $contentT1 = '';
|
|
|
+ if ($arrProvider['PROV_PAIS'] === 'MEX') {
|
|
|
+ try {
|
|
|
+ $arrEntity = (array) DB::table('S002V01TESTA')
|
|
|
+ ->where('ESTA_NULI', '=', $line)
|
|
|
+ ->where('ESTA_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
+ ->where('ESTA_COPA', '=', $arrProvider['PROV_PAIS'])
|
|
|
+ ->where('ESTA_ESTA', '=', 'Activo')
|
|
|
+ ->first([ 'ESTA_COES', 'ESTA_NOES' ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET016: Ocurrió un error al obtener la información de la entidad federativa.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if ( empty($arrEntity) ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET017: No se encontró la entidad federativa asociada al proveedor.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $contentT1 = $arrEntity['ESTA_NOES'] . ' (' . $arrEntity['ESTA_COES'] . ')';
|
|
|
+ } else {
|
|
|
+ $contentT1 = $arrProvider['PROV_ENTI'];
|
|
|
+ }
|
|
|
+ $activeWorksheet->setCellValue("A20", $headerT1);
|
|
|
+ $activeWorksheet->setCellValue("B20", $contentT1);
|
|
|
+ $activeWorksheet->getStyle( "A20" )->getFont()->setBold(true);
|
|
|
+
|
|
|
+
|
|
|
+ $headerU1 = 'País';
|
|
|
try {
|
|
|
- $arrColony = (array) DB::table('S002V01TCOLO')
|
|
|
- ->where('COLO_NULI', '=', $line)
|
|
|
- ->where('COLO_COCO', '=', $arrProvider['PROV_COLO'])
|
|
|
- ->where('COLO_COPO', '=', $arrProvider['PROV_COPO'])
|
|
|
- ->where('COLO_ESTA', '=', 'Activo')
|
|
|
- ->first([ 'COLO_COCO', 'COLO_NOCO' ]);
|
|
|
+ $arrCountry = (array) DB::table('S002V01TPAIS')
|
|
|
+ ->where('PAIS_NULI', '=', $line)
|
|
|
+ ->where('PAIS_IDPA', '=', $arrProvider['PROV_PAIS'])
|
|
|
+ ->first([ 'PAIS_IDPA', 'PAIS_NOMB' ]);
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: Ocurrió un error al obtener la información de la colonia.",
|
|
|
+ "ERR_PROVIDER_SHEET018: Ocurrió un error al obtener la información del país.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
- if ( empty($arrColony) ) {
|
|
|
+ if ( empty($arrCountry) ) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: No se encontró la colonia asociada al proveedor.",
|
|
|
+ "ERR_PROVIDER_SHEET019: No se encontró el país asociado al proveedor.",
|
|
|
[],
|
|
|
500
|
|
|
);
|
|
|
+ }
|
|
|
+ $contentU1 = $arrCountry['PAIS_NOMB'] . ' (' . $arrCountry['PAIS_IDPA'] . ')';
|
|
|
+ $activeWorksheet->setCellValue("A21", $headerU1);
|
|
|
+ $activeWorksheet->setCellValue("B21", $contentU1);
|
|
|
+ $activeWorksheet->getStyle( "A21" )->getFont()->setBold(true);
|
|
|
+
|
|
|
+ $activeWorksheet->getColumnDimension("A")->setAutoSize(true);
|
|
|
+ $activeWorksheet->getColumnDimension("B")->setAutoSize(true);
|
|
|
+
|
|
|
+
|
|
|
+ $arrAlphabet = $this->resourcesController->arrAlphabet;
|
|
|
+
|
|
|
+
|
|
|
+ $spreadsheet->createSheet();
|
|
|
+ $spreadsheet->setActiveSheetIndex(1);
|
|
|
+ $activeWorksheetContact = $spreadsheet->getActiveSheet()->setTitle('Contactos');
|
|
|
+ $arrHeaderContact = array(
|
|
|
+ 'ID', // A
|
|
|
+ 'Contacto', // B
|
|
|
+ 'Tipo de Contacto', // C
|
|
|
+ 'Correo Electrónico Principal', // D
|
|
|
+ 'Correo Electrónico Secundario', // E
|
|
|
+ 'Teléfono Principal', // F
|
|
|
+ 'Teléfono Secundario', // G
|
|
|
+ 'Calle', // H
|
|
|
+ 'Número Exterior', // I
|
|
|
+ 'Numero Interior', // J
|
|
|
+ 'Código Postal', // K
|
|
|
+ 'Colonia', // L
|
|
|
+ 'Localidad', // M
|
|
|
+ 'Municipio', // N
|
|
|
+ 'Entidad Federativa', // O
|
|
|
+ 'País', // P
|
|
|
+ 'Observaciones' // Q
|
|
|
+ );
|
|
|
+ foreach ($arrContact as $key => $contact) {
|
|
|
+ $key = $key + 2;
|
|
|
+
|
|
|
+ $activeWorksheetContact->setCellValue("A".$key, $contact['PRCO_IDCP']);
|
|
|
+ $activeWorksheetContact->setCellValue("B".$key, $contact['PRCO_NOMB']);
|
|
|
+ $activeWorksheetContact->setCellValue("C".$key, $contact['PRCO_TIPO']);
|
|
|
+ $activeWorksheetContact->setCellValue("D".$key, $contact['PRCO_COR1']);
|
|
|
+ if ( !is_null( $contact['PRCO_COR2'] ) ) {
|
|
|
+ $activeWorksheetContact->setCellValue("E".$key, $contact['PRCO_COR2']);
|
|
|
+ } else {
|
|
|
+ $activeWorksheetContact->setCellValue("E".$key, 'No aplica' );
|
|
|
+ }
|
|
|
+ $activeWorksheetContact->setCellValue("F".$key, $contact['PRCO_LAD1'] . ' ' . $contact['PRCO_TEL1'] );
|
|
|
+ if ( !is_null( $contact['PRCO_LAD2'] ) && !is_null( $contact['PRCO_TEL2'] ) ) {
|
|
|
+ $activeWorksheetContact->setCellValue("G".$key, $contact['PRCO_LAD2'] . ' ' . $contact['PRCO_TEL2'] );
|
|
|
+ } else {
|
|
|
+ $activeWorksheetContact->setCellValue("G".$key, 'No aplica' );
|
|
|
+ }
|
|
|
+ $activeWorksheetContact->setCellValue("H".$key, $contact['PRCO_CALL'] );
|
|
|
+ $activeWorksheetContact->setCellValue("I".$key, $contact['PRCO_NUEX'] );
|
|
|
+ if ( !is_null( $contact['PRCO_NUIN'] ) ) {
|
|
|
+ $activeWorksheetContact->setCellValue("J".$key, $contact['PRCO_NUIN']);
|
|
|
+ } else {
|
|
|
+ $activeWorksheetContact->setCellValue("J".$key, 'No aplica' );
|
|
|
+ }
|
|
|
+ $activeWorksheetContact->setCellValue("K".$key, $contact['PRCO_COPO'] );
|
|
|
+ $activeWorksheetContact->setCellValue("L".$key, $contact['PRCO_COLO'] );
|
|
|
+ if ( !is_null($contact['PRCO_LOCA']) && $contact['PRCO_LOCA'] !== 'Sin localidad' ) {
|
|
|
+ $activeWorksheetContact->setCellValue("M".$key, $contact['PRCO_LOCA'] );
|
|
|
+ } else {
|
|
|
+ $activeWorksheetContact->setCellValue("M".$key, 'No aplica' );
|
|
|
+ }
|
|
|
+ $activeWorksheetContact->setCellValue("N".$key, $contact['PRCO_MUNI'] );
|
|
|
+ $activeWorksheetContact->setCellValue("O".$key, $contact['PRCO_ENTI'] );
|
|
|
+ $activeWorksheetContact->setCellValue("P".$key, $contact['PRCO_PAIS'] );
|
|
|
+ $activeWorksheetContact->setCellValue("Q".$key, $contact['PRCO_OBSE'] );
|
|
|
+ }
|
|
|
+ foreach ($arrHeaderContact as $keyHeaderContact => $headerContact) {
|
|
|
+ $activeWorksheetContact->setCellValue( $arrAlphabet[$keyHeaderContact]."1", $headerContact);
|
|
|
+ $activeWorksheetContact->getColumnDimension( $arrAlphabet[$keyHeaderContact] )->setAutoSize(true);
|
|
|
+ $activeWorksheetContact->getStyle( $arrAlphabet[$keyHeaderContact]."1" )->getFont()->setBold(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ $spreadsheet->createSheet();
|
|
|
+ $spreadsheet->setActiveSheetIndex(2);
|
|
|
+ $activeWorksheetReference = $spreadsheet->getActiveSheet()->setTitle('Referencias');
|
|
|
+ $arrHeaderReference = array(
|
|
|
+ 'ID', // A
|
|
|
+ 'Empresa', // B
|
|
|
+ 'R.F.C.', // C
|
|
|
+ 'Correo', // D
|
|
|
+ 'Teléfono', // E
|
|
|
+ 'Dirección', // F
|
|
|
+ );
|
|
|
+ foreach ($arrReference as $key => $reference) {
|
|
|
+ $key = $key + 2;
|
|
|
+
|
|
|
+ $activeWorksheetReference->setCellValue("A".$key, $reference['PRRE_IDRE']);
|
|
|
+ $activeWorksheetReference->setCellValue("B".$key, $reference['PRRE_EMPR']);
|
|
|
+ $activeWorksheetReference->setCellValue("C".$key, $reference['PRRE_XRFC']);
|
|
|
+ $activeWorksheetReference->setCellValue("D".$key, $reference['PRRE_CORR']);
|
|
|
+ $activeWorksheetReference->setCellValue("E".$key, $reference['PRRE_LADA'] .' '. $reference['PRRE_TELE']);
|
|
|
+ $activeWorksheetReference->setCellValue("F".$key, $reference['PRRE_DIRE']);
|
|
|
+
|
|
|
+ }
|
|
|
+ foreach ($arrHeaderReference as $keyHeaderReference => $headerReference) {
|
|
|
+ $activeWorksheetReference->setCellValue( $arrAlphabet[$keyHeaderReference]."1", $headerReference);
|
|
|
+ $activeWorksheetReference->getColumnDimension( $arrAlphabet[$keyHeaderReference] )->setAutoSize(true);
|
|
|
+ $activeWorksheetReference->getStyle( $arrAlphabet[$keyHeaderReference]."1" )->getFont()->setBold(true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $spreadsheet->createSheet();
|
|
|
+ $spreadsheet->setActiveSheetIndex(3);
|
|
|
+ $activeWorksheetCatalog = $spreadsheet->getActiveSheet()->setTitle('Catálogos');
|
|
|
+ $arrHeaderCatalog = array(
|
|
|
+ 'ID', // A
|
|
|
+ 'Catálogo', // B
|
|
|
+ 'Descripción', // C
|
|
|
+ 'URL', // D
|
|
|
+ );
|
|
|
+ foreach ($arrCatalog as $key => $catalog) {
|
|
|
+ $key = $key + 2;
|
|
|
+ $activeWorksheetCatalog->setCellValue("A".$key, $catalog['PRCE_IDCE']);
|
|
|
+ $activeWorksheetCatalog->setCellValue("B".$key, $catalog['PRCE_CATA']);
|
|
|
+ $activeWorksheetCatalog->setCellValue("C".$key, $catalog['PRCE_DESC']);
|
|
|
+ $activeWorksheetCatalog->setCellValue("D".$key, $catalog['PRCE_XURL']);
|
|
|
+
|
|
|
+ }
|
|
|
+ foreach ($arrHeaderCatalog as $keyHeaderCatalog => $headerCatalog) {
|
|
|
+ $activeWorksheetCatalog->setCellValue( $arrAlphabet[$keyHeaderCatalog]."1", $headerCatalog);
|
|
|
+ $activeWorksheetCatalog->getColumnDimension( $arrAlphabet[$keyHeaderCatalog] )->setAutoSize(true);
|
|
|
+ $activeWorksheetCatalog->getStyle( $arrAlphabet[$keyHeaderCatalog]."1" )->getFont()->setBold(true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $spreadsheet->createSheet();
|
|
|
+ $spreadsheet->setActiveSheetIndex(4);
|
|
|
+ $activeWorksheetPayment = $spreadsheet->getActiveSheet()->setTitle('Métodos de Pago');
|
|
|
+ $arrHeaderPayment = array(
|
|
|
+ 'ID', // A
|
|
|
+ 'Método de Pago', // B
|
|
|
+ );
|
|
|
+ $cont = 2;
|
|
|
+ foreach ($arrPayment as $key => $payment) {
|
|
|
+ $activeWorksheetPayment->setCellValue("A".$cont, $key);
|
|
|
+ $activeWorksheetPayment->setCellValue("B".$cont, $payment);
|
|
|
+ $cont++;
|
|
|
+ }
|
|
|
+ foreach ($arrHeaderPayment as $keyHeaderPayment => $headerPayment) {
|
|
|
+ $activeWorksheetPayment->setCellValue( $arrAlphabet[$keyHeaderPayment]."1", $headerPayment);
|
|
|
+ $activeWorksheetPayment->getColumnDimension( $arrAlphabet[$keyHeaderPayment] )->setAutoSize(true);
|
|
|
+ $activeWorksheetPayment->getStyle( $arrAlphabet[$keyHeaderPayment]."1" )->getFont()->setBold(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ $spreadsheet->createSheet();
|
|
|
+ $spreadsheet->setActiveSheetIndex(5);
|
|
|
+ $activeWorksheetCondition = $spreadsheet->getActiveSheet()->setTitle('Condiciones');
|
|
|
+ $arrHeaderCondition = array(
|
|
|
+ 'ID', // A
|
|
|
+ 'Tipo de Condición', // B
|
|
|
+ 'Información', // C
|
|
|
+ );
|
|
|
+ foreach ($arrCondition as $key => $condition) {
|
|
|
+ $key = $key + 2;
|
|
|
+ $activeWorksheetCondition->setCellValue("A".$key, $condition['PRCN_IDCM']);
|
|
|
+ $activeWorksheetCondition->setCellValue("B".$key, $condition['PRCN_TIPO']);
|
|
|
+ $activeWorksheetCondition->setCellValue("C".$key, $condition['PRCN_INFO']);
|
|
|
+
|
|
|
+ }
|
|
|
+ foreach ($arrHeaderCondition as $keyHeaderCondition => $headerCondition) {
|
|
|
+ $activeWorksheetCondition->setCellValue( $arrAlphabet[$keyHeaderCondition]."1", $headerCondition);
|
|
|
+ $activeWorksheetCondition->getColumnDimension( $arrAlphabet[$keyHeaderCondition] )->setAutoSize(true);
|
|
|
+ $activeWorksheetCondition->getStyle( $arrAlphabet[$keyHeaderCondition]."1" )->getFont()->setBold(true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $nuli = $this->resourcesController->formatSecuence($line, 2);
|
|
|
+ $como = 'GEAD'; // Código del módulo
|
|
|
+ $cldo = 'IN'; // Código de la clasificación
|
|
|
+ $fecr = date('ymd'); // Fecha en la se carga el archivo
|
|
|
+
|
|
|
+ try {
|
|
|
+ $arrSecuence = (array) DB::table('S002V01TAFAL')
|
|
|
+ ->where('AFAL_COMO', '=', $como)
|
|
|
+ ->where('AFAL_CLDO', '=', $cldo)
|
|
|
+ ->where('AFAL_NULI', '=', $line)
|
|
|
+ ->orderBy('AFAL_NUSE', 'desc')
|
|
|
+ ->first([ 'AFAL_NUSE' ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET020: Ocurrió un error al obtener la información de la secuencia.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
}
|
|
|
- $contentQ1 = $arrColony['COLO_NOCO'] . ' (' . $arrColony['COLO_COCO'] . ')';
|
|
|
- $activeWorksheet->setCellValue("Q1", $headerQ1);
|
|
|
- $activeWorksheet->setCellValue("Q2", $contentQ1);
|
|
|
- $activeWorksheet->getColumnDimension("Q")->setAutoSize(true);
|
|
|
+ $nuse = 1; // Secuencia del documento
|
|
|
+ if ( !empty( $arrSecuence ) && !is_null( $arrSecuence ) ) {
|
|
|
+ $nuse = intval( $arrSecuence['AFAL_NUSE'] ) + 1;
|
|
|
+ }
|
|
|
+ $nuse = $this->resourcesController->formatSecuence($nuse, 6);
|
|
|
+ $nuve = $this->resourcesController->formatSecuence('1', 2);
|
|
|
+ $noar = 'ficha_de_proveedor_' . $arrProvider['PROV_NUPR'];
|
|
|
+ $exte = 'xlsx';
|
|
|
|
|
|
+ $filePath = 'C:/ITTEC/SAM/Dev/SistemaMantenimiento/sistema-mantenimiento-back/public/public_files/';
|
|
|
+ $fileName = $nuli.'-'.$como.'-'.$cldo.'-'.$fecr.'-'.$nuse.'='.$nuve.'='.$noar.'.'.$exte;
|
|
|
|
|
|
- $headerR1 = 'Localidad';
|
|
|
- $contentR1 = '';
|
|
|
- if ( !is_null($arrProvider['PROV_LOCA']) && !empty($arrProvider['PROV_LOCA']) ) {
|
|
|
+ $tempFile = $filePath.$fileName;
|
|
|
+
|
|
|
+ if ( file_exists( $tempFile ) ) {
|
|
|
+ if ( !unlink( $tempFile ) ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET021: Ocurrió un error al eliminar el siguiente archivo: " . $tempFile,
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $writer = new Xlsx($spreadsheet);
|
|
|
+ ob_start();
|
|
|
+ $writer->save('php://output');
|
|
|
+ $base64 = base64_encode(ob_get_clean());
|
|
|
+ $validate = \File::put( $tempFile, base64_decode($base64));
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET022: Ocurrió un error al guardar el documento.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $ubic = Storage::putFile('files', new File($tempFile));
|
|
|
+ $ubic = str_replace("/", "\\", $ubic);
|
|
|
+ $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
|
|
|
+ $tama = filesize($ubic);
|
|
|
+ $usac = json_encode([$user]);
|
|
|
+
|
|
|
+ $now = $this->functionsController->now();
|
|
|
+ $currentDate = $now->toDateTimeString();
|
|
|
+
|
|
|
+ try {
|
|
|
+ $validateInsert = DB::table('S002V01TAFAL')->insert([
|
|
|
+ 'AFAL_NULI' => $line,
|
|
|
+ 'AFAL_COMO' => $como,
|
|
|
+ 'AFAL_CLDO' => $cldo,
|
|
|
+ 'AFAL_FECR' => $fecr,
|
|
|
+ 'AFAL_NUSE' => $nuse,
|
|
|
+ 'AFAL_NUVE' => $nuve,
|
|
|
+ 'AFAL_NOAR' => $noar,
|
|
|
+ 'AFAL_EXTE' => $exte,
|
|
|
+ 'AFAL_TAMA' => $tama,
|
|
|
+ 'AFAL_UBIC' => $ubic,
|
|
|
+ 'AFAL_USAC' => $usac,
|
|
|
+ 'AFAL_USRE' => $user,
|
|
|
+ 'AFAL_FERE' => $currentDate,
|
|
|
+ ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET023: Ocurrió un error guardar los datos a la tabla final de archivos.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( !$validateInsert ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET024: No se pudo guardar la ficha del proveedor en la base de datos.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ $urlPublic = 'http://192.168.100.105:8000/public_files/' . $fileName;
|
|
|
+
|
|
|
+ return $this->responseController->makeResponse(false, "EXITO: Modificación Exitosa", [ 'url' => $urlPublic ]);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function generateSheetProviderPDF($encProvider, $user, $line) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ $idProvider = $this->encController->decrypt($encProvider);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET000: Ocurrió un error al obtener el número del proveedor.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $user = $this->encController->decrypt($user);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ DB::rollBack();
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET001: Ocurrió un error al obtener el usuario.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $arrProvider = (array) DB::table('S002V01TPROV')
|
|
|
+ ->where('PROV_NUPR', '=', $idProvider)
|
|
|
+ ->where('PROV_NULI', '=', $line)
|
|
|
+ ->where('REFI_NULI', '=', $line)
|
|
|
+ ->where('REFI_ESTA', '=', 'Activo')
|
|
|
+ ->join('S002V01TREFI', 'REFI_CRFI', '=', 'PROV_CRFI')
|
|
|
+ ->first([
|
|
|
+ 'PROV_NUPR',
|
|
|
+ 'PROV_IDPS',
|
|
|
+ 'PROV_NOCO',
|
|
|
+ // 'PROV_CRFI',
|
|
|
+ 'PROV_NOMB',
|
|
|
+ 'PROV_APPA',
|
|
|
+ 'PROV_APMA',
|
|
|
+ 'PROV_CORR',
|
|
|
+ 'PROV_LAD1',
|
|
|
+ 'PROV_TEL1',
|
|
|
+ 'PROV_LAD2',
|
|
|
+ 'PROV_TEL2',
|
|
|
+ 'PROV_XRFC',
|
|
|
+ 'PROV_XTAX',
|
|
|
+ 'PROV_TIPO',
|
|
|
+ 'PROV_TICO',
|
|
|
+ 'PROV_SIWE',
|
|
|
+ 'PROV_MEPA',
|
|
|
+ 'PROV_CALL',
|
|
|
+ 'PROV_NUEX',
|
|
|
+ 'PROV_NUIN',
|
|
|
+ 'PROV_COPO',
|
|
|
+ 'PROV_COLO',
|
|
|
+ 'PROV_MUNI',
|
|
|
+ 'PROV_LOCA',
|
|
|
+ 'PROV_ENTI',
|
|
|
+ 'PROV_PAIS',
|
|
|
+ 'PROV_ESTA',
|
|
|
+ 'PROV_INEX',
|
|
|
+ 'PROV_USRE',
|
|
|
+ 'PROV_FERE',
|
|
|
+ 'PROV_USMO',
|
|
|
+ 'PROV_FEMO',
|
|
|
+ 'PROV_FEAR',
|
|
|
+ 'REFI_CRFI',
|
|
|
+ 'REFI_DRFI',
|
|
|
+ ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET002: Ocurrió un error al obtener la información del proveedor.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( empty($arrProvider) ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET003: El proveedor seleccionado no existe.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($arrProvider['PROV_ESTA'] !== 'Activo') {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET004: El proveedor seleccionado no se encuentra activo.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $arrReference = DB::table('S002V01TPRRE')
|
|
|
+ ->where('PRRE_NUPR', '=', $idProvider)
|
|
|
+ ->where('PRRE_NULI', '=', $line)
|
|
|
+ ->where('PRRE_ESTA', '=', 'Activo')
|
|
|
+ ->get([
|
|
|
+ 'PRRE_IDRE',
|
|
|
+ 'PRRE_EMPR',
|
|
|
+ 'PRRE_CORR',
|
|
|
+ 'PRRE_LADA',
|
|
|
+ 'PRRE_TELE',
|
|
|
+ 'PRRE_XRFC',
|
|
|
+ 'PRRE_DIRE',
|
|
|
+ ]);
|
|
|
+ $arrReference = json_decode( json_encode($arrReference), true );
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET005: Ocurrió un error al obtener las referencias del proveedor.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $arrContact = DB::table('S002V01TPRCO')
|
|
|
+ ->where('PRCO_NUPR', '=', $idProvider)
|
|
|
+ ->where('PRCO_NULI', '=', $line)
|
|
|
+ ->where('PRCO_ESTA', '=', 'Activo')
|
|
|
+ ->get([
|
|
|
+ 'PRCO_IDCP',
|
|
|
+ 'PRCO_NOMB',
|
|
|
+ 'PRCO_TIPO',
|
|
|
+ 'PRCO_CALL',
|
|
|
+ 'PRCO_NUEX',
|
|
|
+ 'PRCO_NUIN',
|
|
|
+ 'PRCO_COPO',
|
|
|
+ 'PRCO_COLO',
|
|
|
+ 'PRCO_LOCA',
|
|
|
+ 'PRCO_MUNI',
|
|
|
+ 'PRCO_ENTI',
|
|
|
+ 'PRCO_PAIS',
|
|
|
+ 'PRCO_LAD1',
|
|
|
+ 'PRCO_TEL1',
|
|
|
+ 'PRCO_LAD2',
|
|
|
+ 'PRCO_TEL2',
|
|
|
+ 'PRCO_COR1',
|
|
|
+ 'PRCO_COR2',
|
|
|
+ 'PRCO_OBSE',
|
|
|
+ ]);
|
|
|
+ $arrContact = json_decode( json_encode($arrContact), true );
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET006: Ocurrió un error al obtener los contactos del proveedor.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $arrCondition = DB::table('S002V01TPRCN')
|
|
|
+ ->where('PRCN_NUPR', '=', $idProvider)
|
|
|
+ ->where('PRCN_NULI', '=', $line)
|
|
|
+ ->where('PRCN_ESTA', '=', 'Activo')
|
|
|
+ ->get([
|
|
|
+ 'PRCN_IDCM',
|
|
|
+ 'PRCN_TIPO',
|
|
|
+ 'PRCN_INFO',
|
|
|
+ ]);
|
|
|
+ $arrCondition = json_decode( json_encode($arrCondition), true );
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET007: Ocurrió un error al obtener las condiciones del proveedor.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $arrCatalog = DB::table('S002V01TPRCE')
|
|
|
+ ->where('PRCE_NUPR', '=', $idProvider)
|
|
|
+ ->where('PRCE_NULI', '=', $line)
|
|
|
+ ->where('PRCE_ESTA', '=', 'Activo')
|
|
|
+ ->get([
|
|
|
+ 'PRCE_IDCE',
|
|
|
+ 'PRCE_CATA',
|
|
|
+ 'PRCE_DESC',
|
|
|
+ 'PRCE_XURL',
|
|
|
+ ]);
|
|
|
+ $arrCatalog = json_decode( json_encode($arrCatalog), true );
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET008: Ocurrió un error al obtener los catálogos del proveedor.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $arrPayment = json_decode($arrProvider['PROV_MEPA']);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET009: El proveedor seleccionado no se encuentra activo.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ $arrProvider['CONDITION'] = $arrCondition;
|
|
|
+ $arrProvider['CATALOG'] = $arrCatalog;
|
|
|
+ $arrProvider['PROV_MEPA'] = $arrPayment;
|
|
|
+
|
|
|
+ $html = '<!DOCTYPE html>
|
|
|
+ <html lang="en">
|
|
|
+ <head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+ <style>
|
|
|
+ body {
|
|
|
+ font-family: Arial, Helvetica, sans-serif;
|
|
|
+ font-size: 8pt;
|
|
|
+ }
|
|
|
+ .section-title {
|
|
|
+ margin: 20px 0;
|
|
|
+ font-size: 12pt;
|
|
|
+ }
|
|
|
+
|
|
|
+ table {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ thead tr th {
|
|
|
+ text-align: start;
|
|
|
+ padding: 0 16px;
|
|
|
+ height: 52px;
|
|
|
+ border-bottom-width: 1px;
|
|
|
+ border-bottom-style: solid;
|
|
|
+ border-bottom-color: #CCC;
|
|
|
+ }
|
|
|
+
|
|
|
+ tbody tr td {
|
|
|
+ padding: 0 16px;
|
|
|
+ height: 52px;
|
|
|
+ border-bottom-width: 1px;
|
|
|
+ border-bottom-style: solid;
|
|
|
+ border-bottom-color: #CCC;
|
|
|
+ }
|
|
|
+
|
|
|
+ p {
|
|
|
+ text-align: justify;
|
|
|
+ }
|
|
|
+
|
|
|
+ </style>
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <div class="item">
|
|
|
+ <b>Número Proveedor:</b>
|
|
|
+ <span>'.$arrProvider['PROV_NUPR'].'</span>
|
|
|
+ </div>
|
|
|
+ <div class="item">
|
|
|
+ <b>Nombre Comercial: </b>
|
|
|
+ <span>'.$arrProvider['PROV_NOCO'].'</span>
|
|
|
+ </div>
|
|
|
+ <div class="item">
|
|
|
+ <b>Responsable: </b>
|
|
|
+ <span>'.$arrProvider['PROV_NOMB'].' '.$arrProvider['PROV_APPA'].' '.$arrProvider['PROV_APMA'].'</span>
|
|
|
+ </div>
|
|
|
+ <div class="item">
|
|
|
+ <b>Correo electrónico: </b>
|
|
|
+ <span>'.$arrProvider['PROV_CORR'].'</span>
|
|
|
+ </div>';
|
|
|
+
|
|
|
+ if ($arrProvider['PROV_XRFC'] !== null && $arrProvider['PROV_XRFC'] !== '' && ($arrProvider['PROV_XTAX'] === '' || $arrProvider['PROV_XTAX'] === null)) {
|
|
|
+ $html.='<div class="item">
|
|
|
+ <b>R.F.C: </b>
|
|
|
+ <span>'.$arrProvider['PROV_XRFC'].'</span>
|
|
|
+ </div>';
|
|
|
+ } else if ($arrProvider['PROV_XTAX'] !== null && $arrProvider['PROV_XTAX'] !== '' && ($arrProvider['PROV_XRFC'] === '' || $arrProvider['PROV_XRFC'] === null)) {
|
|
|
+ $html.='<div class="item">
|
|
|
+ <b>TAX ID: </b>
|
|
|
+ <span>'.$arrProvider['PROV_XTAX'].'</span>
|
|
|
+ </div>';
|
|
|
+ } else {
|
|
|
+ $html.='<div class="item">
|
|
|
+ <b>R.F.C / TAX ID: </b>
|
|
|
+ <span> Sin contenido </span>
|
|
|
+ </div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $html.='<div class="item">
|
|
|
+ <b>Régimen fiscal: </b>
|
|
|
+ <span>'.$arrProvider['REFI_DRFI'] . ' (' . $arrProvider['REFI_CRFI'] . ')'.'</span>
|
|
|
+ </div>
|
|
|
+ <div class="item">
|
|
|
+ <b>Tipo de ciudadania: </b>
|
|
|
+ <span>'.$arrProvider['PROV_TIPO'].'</span>
|
|
|
+ </div>
|
|
|
+ <div class="item">
|
|
|
+ <b>Tipo de contribuyente: </b>
|
|
|
+ <span>'.$arrProvider['PROV_TICO'].'</span>
|
|
|
+ </div>
|
|
|
+ <div class="item">
|
|
|
+ <b>Teléfono principal: </b>
|
|
|
+ <span>'.'('.$arrProvider['PROV_LAD1'] .') '. $arrProvider['PROV_TEL1'].'</span>
|
|
|
+ </div>';
|
|
|
+
|
|
|
+ if ($arrProvider['PROV_LAD2'] !== null && $arrProvider['PROV_LAD2'] !== '' && $arrProvider['PROV_TEL2'] !== null && $arrProvider['PROV_TEL2'] !== '') {
|
|
|
+ $html.='<div class="item">
|
|
|
+ <b>Teléfono secundario: </b>
|
|
|
+ <span>'.'('.$arrProvider['PROV_LAD2'] .') '. $arrProvider['PROV_TEL2'].'</span>
|
|
|
+ </div>';
|
|
|
+ } else {
|
|
|
+ $html.='<div class="item">
|
|
|
+ <b>Teléfono secundario: </b>
|
|
|
+ <span>No aplica</span>
|
|
|
+ </div>';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($arrProvider['PROV_SIWE'] !== null && $arrProvider['PROV_SIWE'] !== '') {
|
|
|
+ $html.='<div class="item">
|
|
|
+ <b>Enlace de sitio web: </b>
|
|
|
+ <span>'.$arrProvider['PROV_SIWE'].'</span>
|
|
|
+ </div>';
|
|
|
+ } else {
|
|
|
+ $html.='<div class="item">
|
|
|
+ <b>Enlace de sitio web: </b>
|
|
|
+ <span>No aplica</span>
|
|
|
+ </div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $address = $arrProvider['PROV_CALL'].' '.$arrProvider['PROV_NUEX'] . ' ';
|
|
|
+ if ($arrProvider['PROV_NUIN'] !== null && $arrProvider['PROV_NUIN'] !== '') {
|
|
|
+ $address .= $arrProvider['PROV_NUIN'] . ' ';
|
|
|
+ }
|
|
|
+ $address .= $arrProvider['PROV_COPO'] . ', ';
|
|
|
+
|
|
|
+ if ($arrProvider['PROV_PAIS'] === 'MEX') {
|
|
|
try {
|
|
|
- $arrLocate = (array) DB::table('S002V01TLOCA')
|
|
|
- ->where('LOCA_NULI', '=', $line)
|
|
|
- ->where('LOCA_COLO', '=', $arrProvider['PROV_LOCA'])
|
|
|
- ->where('LOCA_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
- ->where('LOCA_ESTA', '=', 'Activo')
|
|
|
- ->first([ 'LOCA_COLO', 'LOCA_NOLO' ]);
|
|
|
+ $arrColony = (array) DB::table('S002V01TCOLO')
|
|
|
+ ->where('COLO_NULI', '=', $line)
|
|
|
+ ->where('COLO_COCO', '=', $arrProvider['PROV_COLO'])
|
|
|
+ ->where('COLO_COPO', '=', $arrProvider['PROV_COPO'])
|
|
|
+ ->where('COLO_ESTA', '=', 'Activo')
|
|
|
+ ->first([ 'COLO_COCO', 'COLO_NOCO' ]);
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: Ocurrió un error al obtener la información de la localidad.",
|
|
|
+ "ERR_PROVIDER_SHEET010: Ocurrió un error al obtener la información de la colonia.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
- if ( empty($arrLocate) ) {
|
|
|
+ if ( empty($arrColony) ) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: No se encontró la localidad asociada al proveedor.",
|
|
|
+ "ERR_PROVIDER_SHEET011: No se encontró la colonia asociada al proveedor.",
|
|
|
[],
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
+ $address .= $arrColony['COLO_NOCO'] . ', ';
|
|
|
+ } else {
|
|
|
+ $address .= $arrProvider['PROV_COLO'] . ', ';
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- $contentR1 = $arrLocate['LOCA_NOLO'] . ' (' . $arrLocate['LOCA_NOLO'] . ')';
|
|
|
+ if ($arrProvider['PROV_PAIS'] === 'MEX') {
|
|
|
+ if ( !is_null($arrProvider['PROV_LOCA']) && !empty($arrProvider['PROV_LOCA']) ) {
|
|
|
+ try {
|
|
|
+ $arrLocate = (array) DB::table('S002V01TLOCA')
|
|
|
+ ->where('LOCA_NULI', '=', $line)
|
|
|
+ ->where('LOCA_COLO', '=', $arrProvider['PROV_LOCA'])
|
|
|
+ ->where('LOCA_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
+ ->where('LOCA_ESTA', '=', 'Activo')
|
|
|
+ ->first([ 'LOCA_COLO', 'LOCA_NOLO' ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET012: Ocurrió un error al obtener la información de la localidad.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( empty($arrLocate) ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET013: No se encontró la localidad asociada al proveedor.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ $address .= $arrLocate['LOCA_NOLO'] . ', ';
|
|
|
+ }
|
|
|
} else {
|
|
|
- $contentR1 = 'Sin localidad';
|
|
|
+ if ( !is_null($arrProvider['PROV_LOCA']) && !empty($arrProvider['PROV_LOCA']) ) {
|
|
|
+ $address .= $arrProvider['PROV_LOCA'] . ', ';
|
|
|
+ }
|
|
|
}
|
|
|
- $activeWorksheet->setCellValue("R1", $headerR1);
|
|
|
- $activeWorksheet->setCellValue("R2", $contentR1);
|
|
|
- $activeWorksheet->getColumnDimension("R")->setAutoSize(true);
|
|
|
+
|
|
|
+
|
|
|
+ if ($arrProvider['PROV_PAIS'] === 'MEX') {
|
|
|
+ try {
|
|
|
+ $arrMunicipality = (array) DB::table('S002V01TMUNI')
|
|
|
+ ->where('MUNI_NULI', '=', $line)
|
|
|
+ ->where('MUNI_COMU', '=', $arrProvider['PROV_MUNI'])
|
|
|
+ ->where('MUNI_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
+ ->where('MUNI_ESTA', '=', 'Activo')
|
|
|
+ ->first([ 'MUNI_COMU', 'MUNI_NOMU' ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET014: Ocurrió un error al obtener la información del municipio.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if ( empty($arrMunicipality) ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET015: No se encontró el municipio asociada al proveedor.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $address .= $arrMunicipality['MUNI_NOMU'] . ', ';
|
|
|
+ } else {
|
|
|
+ $address .= $arrProvider['PROV_MUNI'] . ', ';
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ if ($arrProvider['PROV_PAIS'] === 'MEX') {
|
|
|
+ try {
|
|
|
+ $arrEntity = (array) DB::table('S002V01TESTA')
|
|
|
+ ->where('ESTA_NULI', '=', $line)
|
|
|
+ ->where('ESTA_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
+ ->where('ESTA_COPA', '=', $arrProvider['PROV_PAIS'])
|
|
|
+ ->where('ESTA_ESTA', '=', 'Activo')
|
|
|
+ ->first([ 'ESTA_COES', 'ESTA_NOES' ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET016: Ocurrió un error al obtener la información de la entidad federativa.",
|
|
|
+ $th->getMessage(),
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if ( empty($arrEntity) ) {
|
|
|
+ return $this->responseController->makeResponse(
|
|
|
+ true,
|
|
|
+ "ERR_PROVIDER_SHEET017: No se encontró la entidad federativa asociada al proveedor.",
|
|
|
+ [],
|
|
|
+ 500
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $address .= $arrEntity['ESTA_NOES'] . ', ';
|
|
|
+ } else {
|
|
|
+ $address .= $arrProvider['PROV_ENTI'] . ', ';
|
|
|
+ }
|
|
|
|
|
|
- $headerS1 = 'Municipio';
|
|
|
- $contentS1 = '';
|
|
|
try {
|
|
|
- $arrMunicipality = (array) DB::table('S002V01TMUNI')
|
|
|
- ->where('MUNI_NULI', '=', $line)
|
|
|
- ->where('MUNI_COMU', '=', $arrProvider['PROV_MUNI'])
|
|
|
- ->where('MUNI_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
- ->where('MUNI_ESTA', '=', 'Activo')
|
|
|
- ->first([ 'MUNI_COMU', 'MUNI_NOMU' ]);
|
|
|
+ $arrCountry = (array) DB::table('S002V01TPAIS')
|
|
|
+ ->where('PAIS_NULI', '=', $line)
|
|
|
+ ->where('PAIS_IDPA', '=', $arrProvider['PROV_PAIS'])
|
|
|
+ ->first([ 'PAIS_IDPA', 'PAIS_NOMB' ]);
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: Ocurrió un error al obtener la información del municipio.",
|
|
|
+ "ERR_PROVIDER_SHEET018: Ocurrió un error al obtener la información del país.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
- if ( empty($arrMunicipality) ) {
|
|
|
+ if ( empty($arrCountry) ) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: No se encontró el municipio asociada al proveedor.",
|
|
|
+ "ERR_PROVIDER_SHEET019: No se encontró el país asociado al proveedor.",
|
|
|
[],
|
|
|
500
|
|
|
);
|
|
|
+ }
|
|
|
+ $address .= $arrCountry['PAIS_NOMB'] . '.';
|
|
|
+
|
|
|
+
|
|
|
+ $html.='<div class="item">
|
|
|
+ <b>Dirección: </b>
|
|
|
+ <span>'.$address.'</span>
|
|
|
+ </div>';
|
|
|
+
|
|
|
+
|
|
|
+ if ( !empty($arrContact) ) {
|
|
|
+ $html.='<div class="section-title">
|
|
|
+ <b>Contactos</b>
|
|
|
+ </div>';
|
|
|
+ $html.='<table cellspacing="0" cellpadding="0">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>ID</th>
|
|
|
+ <th>Contacto</th>
|
|
|
+ <th>Tipo de Contacto</th>
|
|
|
+ <th>Correo Electrónico</th>
|
|
|
+ <th>Teléfono</th>
|
|
|
+ <th>Direcciones</th>
|
|
|
+ <th>Observaciones</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>';
|
|
|
+ foreach ($arrContact as $keyContact => $contact) {
|
|
|
+ $html.= '<tr>
|
|
|
+ <td>'.$contact['PRCO_IDCP'].'</td>
|
|
|
+ <td>'.$contact['PRCO_NOMB'].'</td>
|
|
|
+ <td>'.$contact['PRCO_TIPO'].'</td>
|
|
|
+ <td>'.$contact['PRCO_COR1'].'</td>
|
|
|
+ <td>'.$contact['PRCO_LAD1'].' '.$contact['PRCO_TEL1'].'</td>
|
|
|
+ <td>'.$contact['PRCO_CALL'].'</td>
|
|
|
+ <td>'.$contact['PRCO_OBSE'].'</td>
|
|
|
+ </tr>';
|
|
|
+ }
|
|
|
+ $html.= '</tbody>
|
|
|
+ </table>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( !empty($arrReference) ) {
|
|
|
+ $html.='<div class="section-title">
|
|
|
+ <b>Referencias</b>
|
|
|
+ </div>';
|
|
|
+ $html.='<table cellspacing="0" cellpadding="0">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>ID</th>
|
|
|
+ <th>Empresa</th>
|
|
|
+ <th>R.F.C.</th>
|
|
|
+ <th>Correo Electrónico</th>
|
|
|
+ <th>Teléfono</th>
|
|
|
+ <th>Dirección</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>';
|
|
|
+ foreach ($arrReference as $keyReference => $reference) {
|
|
|
+ $html.= '<tr>
|
|
|
+ <td>'.$reference['PRRE_IDRE'].'</td>
|
|
|
+ <td>'.$reference['PRRE_EMPR'].'</td>
|
|
|
+ <td>'.$reference['PRRE_XRFC'].'</td>
|
|
|
+ <td>'.$reference['PRRE_CORR'].'</td>
|
|
|
+ <td>'.$reference['PRRE_LADA'].' '.$reference['PRRE_TELE'].'</td>
|
|
|
+ <td>'.$reference['PRRE_DIRE'].'</td>
|
|
|
+ </tr>';
|
|
|
+ }
|
|
|
+ $html.= '</tbody>
|
|
|
+ </table>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( !empty($arrPayment) ) {
|
|
|
+ $html.='<div class="section-title">
|
|
|
+ <b>Métodos de Pago</b>
|
|
|
+ </div>';
|
|
|
+
|
|
|
+ $html.='<ol style="margin: 0;">';
|
|
|
+ foreach ($arrPayment as $keyPayment => $payment) {
|
|
|
+ $html.='<li>'.$payment.'</li>';
|
|
|
+ }
|
|
|
+ $html.='</ol>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( !empty($arrCatalog) ) {
|
|
|
+ $html.='<div class="section-title">
|
|
|
+ <b>Catálogos</b>
|
|
|
+ </div>';
|
|
|
+
|
|
|
+ $html.='<table cellspacing="0" cellpadding="0">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>ID</th>
|
|
|
+ <th>Catálogo</th>
|
|
|
+ <th>Descripción</th>
|
|
|
+ <th>URL</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>';
|
|
|
+ foreach ($arrCatalog as $keyCatalog => $catalog) {
|
|
|
+ $html.= '<tr>
|
|
|
+ <td>'.$catalog['PRCE_IDCE'].'</td>
|
|
|
+ <td>'.$catalog['PRCE_CATA'].'</td>
|
|
|
+ <td>'.$catalog['PRCE_DESC'].'</td>
|
|
|
+ <td>'.$catalog['PRCE_XURL'].'</td>
|
|
|
+ </tr>';
|
|
|
+ }
|
|
|
+ $html.= '</tbody>
|
|
|
+ </table>';
|
|
|
}
|
|
|
- $contentS1 = $arrMunicipality['MUNI_NOMU'] . ' (' . $arrMunicipality['MUNI_COMU'] . ')';
|
|
|
- $activeWorksheet->setCellValue("S1", $headerS1);
|
|
|
- $activeWorksheet->setCellValue("S2", $contentS1);
|
|
|
- $activeWorksheet->getColumnDimension("S")->setAutoSize(true);
|
|
|
|
|
|
+ if ( !empty($arrCondition) ) {
|
|
|
+ foreach ($arrCondition as $keyCondition => $condition) {
|
|
|
+ $html.='<div class="section-title">
|
|
|
+ <b>'.$condition['PRCN_TIPO'].'</b>
|
|
|
+ </div>';
|
|
|
+ $html.='<p>'.$condition['PRCN_INFO'].'</p>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $html.='</body></html>';
|
|
|
+
|
|
|
+ $nuli = $this->resourcesController->formatSecuence($line, 2);
|
|
|
+ $como = 'GEAD'; // Código del módulo
|
|
|
+ $cldo = 'IN'; // Código de la clasificación
|
|
|
+ $fecr = date('ymd'); // Fecha en la se carga el archivo
|
|
|
|
|
|
- $headerT1 = 'Entidad Federativa';
|
|
|
- $contentT1 = '';
|
|
|
try {
|
|
|
- $arrEntity = (array) DB::table('S002V01TESTA')
|
|
|
- ->where('ESTA_NULI', '=', $line)
|
|
|
- ->where('ESTA_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
- ->where('ESTA_COPA', '=', $arrProvider['PROV_PAIS'])
|
|
|
- ->where('ESTA_ESTA', '=', 'Activo')
|
|
|
- ->first([ 'ESTA_COES', 'ESTA_NOES' ]);
|
|
|
+ $arrSecuence = (array) DB::table('S002V01TAFAL')
|
|
|
+ ->where('AFAL_COMO', '=', $como)
|
|
|
+ ->where('AFAL_CLDO', '=', $cldo)
|
|
|
+ ->where('AFAL_NULI', '=', $line)
|
|
|
+ ->orderBy('AFAL_NUSE', 'desc')
|
|
|
+ ->first([ 'AFAL_NUSE' ]);
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: Ocurrió un error al obtener la información de la entidad federativa.",
|
|
|
+ "ERR_PROVIDER_SHEET020: Ocurrió un error al obtener la información de la secuencia.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
- if ( empty($arrEntity) ) {
|
|
|
+ $nuse = 1; // Secuencia del documento
|
|
|
+ if ( !empty( $arrSecuence ) && !is_null( $arrSecuence ) ) {
|
|
|
+ $nuse = intval( $arrSecuence['AFAL_NUSE'] ) + 1;
|
|
|
+ }
|
|
|
+ $nuse = $this->resourcesController->formatSecuence($nuse, 6);
|
|
|
+ $nuve = $this->resourcesController->formatSecuence('1', 2);
|
|
|
+ $noar = 'ficha_de_proveedor_' . $arrProvider['PROV_NUPR'];
|
|
|
+
|
|
|
+ $nuli = $this->resourcesController->formatSecuence($line, 2);
|
|
|
+ $como = 'GEAD'; // Código del módulo
|
|
|
+ $cldo = 'IN'; // Código de la clasificación
|
|
|
+ $fecr = date('ymd'); // Fecha en la se carga el archivo
|
|
|
+ try {
|
|
|
+ $arrSecuence = (array) DB::table('S002V01TAFAL')
|
|
|
+ ->where('AFAL_COMO', '=', $como)
|
|
|
+ ->where('AFAL_CLDO', '=', $cldo)
|
|
|
+ ->where('AFAL_NULI', '=', $line)
|
|
|
+ ->orderBy('AFAL_NUSE', 'desc')
|
|
|
+ ->first([ 'AFAL_NUSE' ]);
|
|
|
+ } catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: No se encontró la entidad federativa asociada al proveedor.",
|
|
|
- [],
|
|
|
+ "ERR_PROVIDER_SHEET020: Ocurrió un error al obtener la información de la secuencia.",
|
|
|
+ $th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
- $contentT1 = $arrEntity['ESTA_NOES'] . ' (' . $arrEntity['ESTA_COES'] . ')';
|
|
|
- $activeWorksheet->setCellValue("T1", $headerT1);
|
|
|
- $activeWorksheet->setCellValue("T2", $contentT1);
|
|
|
- $activeWorksheet->getColumnDimension("T")->setAutoSize(true);
|
|
|
+ $nuse = 1; // Secuencia del documento
|
|
|
+ if ( !empty( $arrSecuence ) && !is_null( $arrSecuence ) ) {
|
|
|
+ $nuse = intval( $arrSecuence['AFAL_NUSE'] ) + 1;
|
|
|
+ }
|
|
|
+ $nuse = $this->resourcesController->formatSecuence($nuse, 6);
|
|
|
+ $nuve = $this->resourcesController->formatSecuence('1', 2);
|
|
|
+ $noar = 'ficha_de_proveedor_' . $arrProvider['PROV_NUPR'];
|
|
|
+ $exte = 'pdf';
|
|
|
+
|
|
|
+
|
|
|
+ $filePath = 'C:/ITTEC/SAM/Dev/SistemaMantenimiento/sistema-mantenimiento-back/public/public_files/';
|
|
|
+ $fileName = $nuli.'-'.$como.'-'.$cldo.'-'.$fecr.'-'.$nuse.'='.$nuve.'='.$noar.'.'.$exte;
|
|
|
+
|
|
|
+ $tempFile = $filePath . $fileName;
|
|
|
+
|
|
|
+ $dompdf = new Dompdf();
|
|
|
+ $dompdf ->loadHtml($html);
|
|
|
+ $dompdf->setPaper('A4', 'portrait');
|
|
|
+ $dompdf->render();
|
|
|
+
|
|
|
|
|
|
+ $output = $dompdf->output();
|
|
|
+ file_put_contents($tempFile, $output);
|
|
|
+ $ubic = Storage::putFile('files', new File($tempFile));
|
|
|
+
|
|
|
+ $ubic = str_replace("/", "\\", $ubic);
|
|
|
+ $ubic = "C:\ITTEC\SAM\Dev\SistemaMantenimiento\sistema-mantenimiento-back\storage\app\\" . $ubic;
|
|
|
+ $tama = filesize($ubic);
|
|
|
+ $usac = json_encode([$user]);
|
|
|
+
|
|
|
+ $now = $this->functionsController->now();
|
|
|
+ $currentDate = $now->toDateTimeString();
|
|
|
|
|
|
try {
|
|
|
- $arrEntity = (array) DB::table('S002V01TESTA')
|
|
|
- ->where('ESTA_NULI', '=', $line)
|
|
|
- ->where('ESTA_COES', '=', $arrProvider['PROV_ENTI'])
|
|
|
- ->where('ESTA_COPA', '=', $arrProvider['PROV_PAIS'])
|
|
|
- ->where('ESTA_ESTA', '=', 'Activo')
|
|
|
- ->first([ 'ESTA_COES', 'ESTA_NOES' ]);
|
|
|
+ $validateInsert = DB::table('S002V01TAFAL')->insert([
|
|
|
+ 'AFAL_NULI' => $line,
|
|
|
+ 'AFAL_COMO' => $como,
|
|
|
+ 'AFAL_CLDO' => $cldo,
|
|
|
+ 'AFAL_FECR' => $fecr,
|
|
|
+ 'AFAL_NUSE' => $nuse,
|
|
|
+ 'AFAL_NUVE' => $nuve,
|
|
|
+ 'AFAL_NOAR' => $noar,
|
|
|
+ 'AFAL_EXTE' => $exte,
|
|
|
+ 'AFAL_TAMA' => $tama,
|
|
|
+ 'AFAL_UBIC' => $ubic,
|
|
|
+ 'AFAL_USAC' => $usac,
|
|
|
+ 'AFAL_USRE' => $user,
|
|
|
+ 'AFAL_FERE' => $currentDate,
|
|
|
+ ]);
|
|
|
} catch (\Throwable $th) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: Ocurrió un error al obtener la información de la entidad federativa.",
|
|
|
+ "ERR_PROVIDER_SHEET023: Ocurrió un error guardar los datos a la tabla final de archivos.",
|
|
|
$th->getMessage(),
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
- $headerU1 = 'País';
|
|
|
- $contentU1 = '';
|
|
|
- $activeWorksheet->setCellValue("U1", $headerU1);
|
|
|
- $activeWorksheet->setCellValue("U2", $contentU1);
|
|
|
- $activeWorksheet->getColumnDimension("U")->setAutoSize(true);
|
|
|
-
|
|
|
-
|
|
|
- /* $headerV1 = '';
|
|
|
- $contentV1 = '';
|
|
|
- $activeWorksheet->setCellValue("V1", $headerV1);
|
|
|
- $activeWorksheet->setCellValue("V2", $contentV1);
|
|
|
- $activeWorksheet->getColumnDimension("V")->setAutoSize(true); */
|
|
|
-
|
|
|
- $writer = new Xlsx($spreadsheet);
|
|
|
- ob_start();
|
|
|
- $writer->save('php://output');
|
|
|
- $base64 = base64_encode(ob_get_clean());
|
|
|
- try {
|
|
|
- $validate = \File::put( storage_path() . '/test.xlsx', base64_decode($base64));
|
|
|
- } catch (\Throwable $th) {
|
|
|
+
|
|
|
+ if ( !$validateInsert ) {
|
|
|
return $this->responseController->makeResponse(
|
|
|
true,
|
|
|
- "ERR_PROVIDER_SHEET009: Ocurrió un error al guardar el documento.",
|
|
|
+ "ERR_PROVIDER_SHEET024: No se pudo guardar la ficha del proveedor en la base de datos.",
|
|
|
[],
|
|
|
500
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- return $arrProvider;
|
|
|
-
|
|
|
+ $urlPublic = 'http://192.168.100.105:8000/public_files/' . $fileName;
|
|
|
|
|
|
- // return $base64;
|
|
|
+ return $this->responseController->makeResponse(false, "EXITO: Modificación Exitosa", [ 'url' => $urlPublic ]);
|
|
|
}
|
|
|
}
|