Browse Source

Merge branch 'dev'

Nermosis 3 years ago
parent
commit
a021c61abd

+ 76 - 74
application/controllers/ExportXls.php View File

1
 <?php
1
 <?php
2
+
2
 defined('BASEPATH') or exit('No direct script access allowed');
3
 defined('BASEPATH') or exit('No direct script access allowed');
3
 
4
 
4
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
5
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
30
     public function exportDatosCompletos()
31
     public function exportDatosCompletos()
31
     {
32
     {
32
         $licitacionesResult = $this->Xlsexport_model->getFullDatosUltimasInsertadas();
33
         $licitacionesResult = $this->Xlsexport_model->getFullDatosUltimasInsertadas();
34
+
33
         $result = array();
35
         $result = array();
34
 
36
 
35
         //$start = $this->starttime();
37
         //$start = $this->starttime();
72
         $spreadsheet = $this->datosCompletosHojaBitacora($spreadsheet, $result);
74
         $spreadsheet = $this->datosCompletosHojaBitacora($spreadsheet, $result);
73
         $spreadsheet = $this->datosCompletosMediosPublicacion($spreadsheet, $result['validNoticeInfo']);
75
         $spreadsheet = $this->datosCompletosMediosPublicacion($spreadsheet, $result['validNoticeInfo']);
74
         $spreadsheet = $this->datosMedioPublicacion($spreadsheet, $result['validNoticeInfoDocumentos']);
76
         $spreadsheet = $this->datosMedioPublicacion($spreadsheet, $result['validNoticeInfoDocumentos']);
75
-        $spreadsheet = $this->datosCriterioAdjudicacion($spreadsheet, $result['tenderFinancial']);
76
-        $spreadsheet = $this->datosCriterioEvaluacionFinanciera($spreadsheet, $result['tenderAwarding']);
77
+        $spreadsheet = $this->datosCriterioAdjudicacion($spreadsheet, $result['tenderAwarding']);
78
+        $spreadsheet = $this->datosCriterioEvaluacionFinanciera($spreadsheet, $result['tenderFinancial']);
77
         $spreadsheet = $this->datosCriterioEvaluacionTecnica($spreadsheet, $result['tenderTecnicos']);
79
         $spreadsheet = $this->datosCriterioEvaluacionTecnica($spreadsheet, $result['tenderTecnicos']);
78
         $spreadsheet = $this->datosRequisitosParticipacion($spreadsheet, $result['tenderQualification']);
80
         $spreadsheet = $this->datosRequisitosParticipacion($spreadsheet, $result['tenderQualification']);
79
 
81
 
122
     public function mapearDatos($licitacionesResult): array
124
     public function mapearDatos($licitacionesResult): array
123
     {
125
     {
124
         $result = array();
126
         $result = array();
127
+
125
         guardar_log("Excel", "Montando array datos licitacion");
128
         guardar_log("Excel", "Montando array datos licitacion");
126
         foreach ($licitacionesResult['datos'] as $licitacion) {
129
         foreach ($licitacionesResult['datos'] as $licitacion) {
127
 
130
 
129
                 'id_licitacion' => $licitacion->id_licitacion,
132
                 'id_licitacion' => $licitacion->id_licitacion,
130
                 "link_uri" => $licitacion->link_uri,
133
                 "link_uri" => $licitacion->link_uri,
131
                 "updated" => $licitacion->updated,
134
                 "updated" => $licitacion->updated,
135
+                'estadoLicitacion' => $licitacion->estadoLicitacion,
132
             );
136
             );
133
             $result['hoja1'][$licitacion->id_licitacion]['contract'] = array(
137
             $result['hoja1'][$licitacion->id_licitacion]['contract'] = array(
134
                 "descripcion" => $licitacion->contrato_status,
138
                 "descripcion" => $licitacion->contrato_status,
180
         }
184
         }
181
 
185
 
182
         guardar_log("Excel", "Consulta Valid notice info");
186
         guardar_log("Excel", "Consulta Valid notice info");
183
-        $result['validNoticeInfo'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_valid_notice_info");
187
+        $result['validNoticeInfo'] = $this->Xlsexport_model->getDatosRelacionadasTablaWithoutLicitacion("global_valid_notice_info", "codice_valid_notice_info", "code", "noticeTypeCode");
184
 
188
 
185
         guardar_log("Excel", "Consulta Valid notice info documentos");
189
         guardar_log("Excel", "Consulta Valid notice info documentos");
186
-        $result['validNoticeInfoDocumentos'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_valid_notice_info_documento");
190
+        $result['validNoticeInfoDocumentos'] = $this->Xlsexport_model->getTablaByFechaLog("global_valid_notice_info_documento");
187
 
191
 
188
         guardar_log("Excel", "Consulta projectLot");
192
         guardar_log("Excel", "Consulta projectLot");
189
         $result['projectLot'] = $this->Xlsexport_model->getProjectLotItem();
193
         $result['projectLot'] = $this->Xlsexport_model->getProjectLotItem();
190
 
194
 
191
         guardar_log("Excel", "Consulta documentos tecnicos");
195
         guardar_log("Excel", "Consulta documentos tecnicos");
192
-        $result['techDocs'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_technical_documents");
196
+        $result['techDocs'] = $this->Xlsexport_model->getTablaByFechaLog("global_technical_documents");
193
 
197
 
194
         guardar_log("Excel", "Consulta documentos legales");
198
         guardar_log("Excel", "Consulta documentos legales");
195
-        $result['legalDocs'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_legal_documents");
199
+        $result['legalDocs'] = $this->Xlsexport_model->getTablaByFechaLog("global_legal_documents");
196
 
200
 
197
         guardar_log("Excel", "Consulta documentos adicionales");
201
         guardar_log("Excel", "Consulta documentos adicionales");
198
-        $result['additDocs'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_additional_documents");
202
+        $result['additDocs'] = $this->Xlsexport_model->getTablaByFechaLog("global_additional_documents");
199
 
203
 
200
         guardar_log("Excel", "Consulta documentos generales");
204
         guardar_log("Excel", "Consulta documentos generales");
201
-        $result['generalDocs'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_general_documents");
205
+        $result['generalDocs'] = $this->Xlsexport_model->getTablaByFechaLog("global_general_documents");
202
 
206
 
203
         guardar_log("Excel", "Consulta tender process");
207
         guardar_log("Excel", "Consulta tender process");
204
         $result['tenderProcess'] = $this->Xlsexport_model->getTenderingTermsCodes();
208
         $result['tenderProcess'] = $this->Xlsexport_model->getTenderingTermsCodes();
205
 
209
 
206
         guardar_log("Excel", "Consulta tender terms");
210
         guardar_log("Excel", "Consulta tender terms");
207
-        $result['tenderingTerms'] = $this->Xlsexport_model->getDatosRelacionadasTablaWithoutLicitacion("maestro_tendering_terms", "relacionada_codigo_tipo_garantia", "code", "guaranteeTypeCode");
211
+        $result['tenderingTerms'] = $this->Xlsexport_model->getDatosRelacionadasTablaWithoutLicitacion("global_tendering_terms", "codice_codigo_tipo_garantia", "code", "guaranteeTypeCode");
208
 
212
 
209
         guardar_log("Excel", "Consulta tender result");
213
         guardar_log("Excel", "Consulta tender result");
210
-        $result['tenderResult'] = $this->Xlsexport_model->getDatosRelacionadasTablaWithoutLicitacion("maestro_tender_result", "relacionada_tender_result", "code", "resultCode");
214
+        $result['tenderResult'] = $this->Xlsexport_model->getDatosRelacionadasTablaWithoutLicitacion("global_tender_result", "codice_tender_result", "code", "resultCode");
211
 
215
 
212
         guardar_log("Excel", "Consulta tender criterio financieros");
216
         guardar_log("Excel", "Consulta tender criterio financieros");
213
-        $result['tenderFinancial'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_tendering_terms_financial_evaluation");
217
+        $result['tenderFinancial'] = $this->Xlsexport_model->getDatosRelacionadasTablaWithoutLicitacion("global_tendering_terms_financial_evaluation", "codice_tendering_terms_financial", "code", "evaluationCriteriaTypeCode");
214
 
218
 
215
         guardar_log("Excel", "Consulta tender criterio adjudicacion");
219
         guardar_log("Excel", "Consulta tender criterio adjudicacion");
216
-        $result['tenderAwarding'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_tendering_terms_awarding_terms");
220
+        $result['tenderAwarding'] = $this->Xlsexport_model->getTablaByFechaLog("global_tendering_terms_awarding_terms");
217
 
221
 
218
         guardar_log("Excel", "Consulta tender criterios tecnicos");
222
         guardar_log("Excel", "Consulta tender criterios tecnicos");
219
-        $result['tenderTecnicos'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_tendering_terms_qualification_request");
223
+        $result['tenderTecnicos'] = $this->Xlsexport_model->getDatosRelacionadasTablaWithoutLicitacion("global_tendering_terms_qualification_request", "codice_tendering_terms_qualification_request", "code", "evaluationCriteriaTypeCode");
220
 
224
 
221
         guardar_log("Excel", "Consulta tender requisitos participacion");
225
         guardar_log("Excel", "Consulta tender requisitos participacion");
222
-        $result['tenderQualification'] = $this->Xlsexport_model->getTablaByFechaLog("maestro_tendering_terms_qualification_request");
226
+        $result['tenderQualification'] = $this->Xlsexport_model->getDatosRelacionadasTablaWithoutLicitacion("global_tendering_terms_specific_terms", "codice_tendering_terms_specific_terms", "code", "evaluationCriteriaTypeCode");
223
 
227
 
224
         return $result;
228
         return $result;
225
     }
229
     }
253
             $sheet->getStyle('C' . $this->filaDatoLicitacion)
257
             $sheet->getStyle('C' . $this->filaDatoLicitacion)
254
                 ->getNumberFormat()
258
                 ->getNumberFormat()
255
                 ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
259
                 ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
260
+            $sheet->setCellValue('D' . $this->filaDatoLicitacion, $row['licitacion']['estadoLicitacion']);
256
             $sheet->setCellValue('E' . $this->filaDatoLicitacion, $primeraPublicacion);
261
             $sheet->setCellValue('E' . $this->filaDatoLicitacion, $primeraPublicacion);
257
             $sheet->getStyle('E' . $this->filaDatoLicitacion)
262
             $sheet->getStyle('E' . $this->filaDatoLicitacion)
258
                 ->getNumberFormat()
263
                 ->getNumberFormat()
271
 
276
 
272
             $sheet->setCellValue('K' . $this->filaDatoLicitacion, $row['locatedParty']['itemClassification_attr']);
277
             $sheet->setCellValue('K' . $this->filaDatoLicitacion, $row['locatedParty']['itemClassification_attr']);
273
             $sheet->setCellValue('L' . $this->filaDatoLicitacion, $row['project']['tipo_contrato']);
278
             $sheet->setCellValue('L' . $this->filaDatoLicitacion, $row['project']['tipo_contrato']);
274
-            $sheet->setCellValue('M' . $this->filaDatoLicitacion, $row['project']['countrySubentityCode'] . " - " . $row['project']['countrySubentity']);
279
+            $sheet->setCellValue('M' . $this->filaDatoLicitacion, $row['project']['countrySubentity']);
275
             $sheet->setCellValue('N' . $this->filaDatoLicitacion, $row['party']['partyName']);
280
             $sheet->setCellValue('N' . $this->filaDatoLicitacion, $row['party']['partyName']);
276
-            $sheet->setCellValue('O' . $this->filaDatoLicitacion, ($row['party']['tipoIdParty'] == "ID_PLATAFORMA") ? $row['party']['partyItem'] : "");
277
-            $sheet->setCellValue('P' . $this->filaDatoLicitacion, ($row['party']['tipoIdParty'] == "NIF") ? $row['party']['partyItem'] : "");
278
-            $sheet->setCellValue('Q' . $this->filaDatoLicitacion, ($row['party']['tipoIdParty'] == "DIR3") ? $row['party']['partyItem'] : "");
279
-            $sheet->setCellValue('R' . $this->filaDatoLicitacion, $row['locatedParty']['buyerProfileURIID']);
280
-            $sheet->setCellValue('S' . $this->filaDatoLicitacion, $row['locatedParty']['tipo_administracion']);
281
-            $sheet->setCellValue('T' . $this->filaDatoLicitacion, $row['party']['codpostal']);
282
-            $sheet->setCellValue('U' . $this->filaDatoLicitacion, $row['tenderProcess']['tipoTender']);
283
-            $sheet->setCellValue('V' . $this->filaDatoLicitacion, $row['tenderProcess']['contrato_sistema']);
284
-            $sheet->setCellValue('W' . $this->filaDatoLicitacion, $row['tenderProcess']['urgency']);
285
-            $sheet->setCellValue('X' . $this->filaDatoLicitacion, $row['tenderProcess']['submision']);
286
-            $sheet->setCellValue('ZY' . $this->filaDatoLicitacion, $row['tenderTerms']['procurementLegislationDocumentReference']);
287
-            $sheet->setCellValue('Z' . $this->filaDatoLicitacion, $row['tenderTerms']['allowedSubcontractTerms']);
288
-            $sheet->setCellValue('AA' . $this->filaDatoLicitacion, $row['project']['durationMesure']);
289
-            $sheet->setCellValue('AB' . $this->filaDatoLicitacion, $row['project']['medida']);
290
-            $sheet->setCellValue('AC' . $this->filaDatoLicitacion, $this->formatFechas($row['project']['duracion_inicio']));
291
-            $sheet->getStyle('AC' . $this->filaDatoLicitacion)
281
+            $sheet->setCellValue('O' . $this->filaDatoLicitacion, ($row['party']['tipoIdParty'] == "DIR3") ? $row['party']['partyItem'] : "");
282
+            $sheet->setCellValue('P' . $this->filaDatoLicitacion, $row['locatedParty']['buyerProfileURIID']);
283
+            $sheet->setCellValue('Q' . $this->filaDatoLicitacion, $row['locatedParty']['tipo_administracion']);
284
+            $sheet->setCellValue('R' . $this->filaDatoLicitacion, $row['party']['codpostal']);
285
+            $sheet->setCellValue('S' . $this->filaDatoLicitacion, $row['tenderProcess']['tipoTender']);
286
+            $sheet->setCellValue('T' . $this->filaDatoLicitacion, $row['tenderProcess']['contrato_sistema']);
287
+            $sheet->setCellValue('U' . $this->filaDatoLicitacion, $row['tenderProcess']['urgency']);
288
+            $sheet->setCellValue('V' . $this->filaDatoLicitacion, $row['tenderProcess']['submision']);
289
+            $sheet->setCellValue('W' . $this->filaDatoLicitacion, $row['tenderTerms']['procurementLegislationDocumentReference']);
290
+            $sheet->setCellValue('X' . $this->filaDatoLicitacion, $row['tenderTerms']['allowedSubcontractTerms']);
291
+            $sheet->setCellValue('Y' . $this->filaDatoLicitacion, $row['project']['durationMesure']);
292
+            $sheet->setCellValue('Z' . $this->filaDatoLicitacion, $row['project']['medida']);
293
+            $sheet->setCellValue('AA' . $this->filaDatoLicitacion, $this->formatFechas($row['project']['duracion_inicio']));
294
+            $sheet->getStyle('AA' . $this->filaDatoLicitacion)
292
                 ->getNumberFormat()
295
                 ->getNumberFormat()
293
                 ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
296
                 ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
294
-            $sheet->setCellValue('AD' . $this->filaDatoLicitacion, $this->formatFechas($row['project']['duracion_fin']));
295
-            $sheet->getStyle('AD' . $this->filaDatoLicitacion)
297
+            $sheet->setCellValue('AB' . $this->filaDatoLicitacion, $this->formatFechas($row['project']['duracion_fin']));
298
+            $sheet->getStyle('AB' . $this->filaDatoLicitacion)
296
                 ->getNumberFormat()
299
                 ->getNumberFormat()
297
                 ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
300
                 ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
298
-            $sheet->setCellValue('AE' . $this->filaDatoLicitacion, $row['project']['contractExtension']);
299
-            $sheet->setCellValue('AF' . $this->filaDatoLicitacion, $row['party']['websiteURI']);
300
-            $sheet->setCellValue('AG' . $this->filaDatoLicitacion, $row['party']['city']);
301
-            $sheet->setCellValue('AH' . $this->filaDatoLicitacion, $row['party']['direccion']);
302
-            $sheet->setCellValue('AI' . $this->filaDatoLicitacion, $row['party']['contact_name']);
303
-            $sheet->setCellValue('AJ' . $this->filaDatoLicitacion, $row['party']['contact_email']);
301
+            $sheet->setCellValue('AC' . $this->filaDatoLicitacion, $row['project']['contractExtension']);
302
+            $sheet->setCellValue('AD' . $this->filaDatoLicitacion, $row['party']['websiteURI']);
303
+            $sheet->setCellValue('AE' . $this->filaDatoLicitacion, $row['party']['city']);
304
+            $sheet->setCellValue('AF' . $this->filaDatoLicitacion, $row['party']['direccion']);
305
+            $sheet->setCellValue('AG' . $this->filaDatoLicitacion, $row['party']['contact_name']);
306
+            $sheet->setCellValue('AH' . $this->filaDatoLicitacion, $row['party']['contact_email']);
304
             $this->filaDatoLicitacion++;
307
             $this->filaDatoLicitacion++;
305
         }
308
         }
306
 
309
 
378
                 guardar_log("Excel", "Escribir datos medio publicacion--" . $contador);
381
                 guardar_log("Excel", "Escribir datos medio publicacion--" . $contador);
379
                 $contador++;
382
                 $contador++;
380
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
383
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
381
-                $sheet->SetCellValue('B' . $aux, $datos['noticeTypeCode']);
384
+                $sheet->SetCellValue('B' . $aux, $datos['code_desc']);
382
                 $sheet->SetCellValue('C' . $aux, $datos['publicationMediaName']);
385
                 $sheet->SetCellValue('C' . $aux, $datos['publicationMediaName']);
383
                 $aux++;
386
                 $aux++;
384
             }
387
             }
449
                     ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
452
                     ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
450
                 $sheet->SetCellValue('M' . $aux, $datos['partyIdentification']);
453
                 $sheet->SetCellValue('M' . $aux, $datos['partyIdentification']);
451
                 $sheet->SetCellValue('N' . $aux, $datos['partyName']);
454
                 $sheet->SetCellValue('N' . $aux, $datos['partyName']);
455
+                $sheet->SetCellValue('O' . $aux, $datos['TaxExclusiveAmount']);
456
+                $sheet->getStyle('O' . $aux)
457
+                    ->getNumberFormat()
458
+                    ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_ACCOUNTING_EUR);
452
 
459
 
453
                 $aux++;
460
                 $aux++;
454
             }
461
             }
481
                 $sheet->getStyle('J' . $aux)
488
                 $sheet->getStyle('J' . $aux)
482
                     ->getNumberFormat()
489
                     ->getNumberFormat()
483
                     ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
490
                     ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
484
-                $sheet->SetCellValue('K' . $aux, $this->formatFechas($datos['deadLineEndTime']));
485
-                $sheet->getStyle('K' . $aux)
486
-                    ->getNumberFormat()
487
-                    ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
491
+                $sheet->SetCellValue('K' . $aux, $datos['deadLineEndTime']);
488
                 $sheet->SetCellValue('L' . $aux, $datos['deadLineDescription']);
492
                 $sheet->SetCellValue('L' . $aux, $datos['deadLineDescription']);
489
                 $sheet->SetCellValue('M' . $aux, $datos['auctionTerms']);
493
                 $sheet->SetCellValue('M' . $aux, $datos['auctionTerms']);
490
                 $sheet->SetCellValue('N' . $aux, $this->formatFechas($datos['documentAvailablePeriod_EndDate']));
494
                 $sheet->SetCellValue('N' . $aux, $this->formatFechas($datos['documentAvailablePeriod_EndDate']));
541
                 guardar_log("Excel", "Escribir criterio adjucicacion--" . $contador);
545
                 guardar_log("Excel", "Escribir criterio adjucicacion--" . $contador);
542
                 $contador++;
546
                 $contador++;
543
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
547
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
544
-                $sheet->SetCellValue('B' . $aux, $datos['evaluationCriteriaTypeCode']);
545
                 $sheet->SetCellValue('B' . $aux, $datos['description']);
548
                 $sheet->SetCellValue('B' . $aux, $datos['description']);
549
+                $sheet->SetCellValue('C' . $aux, $datos['evaluationCriteriaTypeCode']);
546
                 $aux++;
550
                 $aux++;
547
             }
551
             }
548
         }
552
         }
562
                 guardar_log("Excel", "Escribir criterios evaluacion financiera--" . $contador);
566
                 guardar_log("Excel", "Escribir criterios evaluacion financiera--" . $contador);
563
                 $contador++;
567
                 $contador++;
564
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
568
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
565
-                $sheet->SetCellValue('B' . $aux, $datos['evaluationCriteriaTypeCode']);
569
+                $sheet->SetCellValue('B' . $aux, $datos['code_desc']);
566
                 $sheet->SetCellValue('C' . $aux, $datos['description']);
570
                 $sheet->SetCellValue('C' . $aux, $datos['description']);
567
                 $aux++;
571
                 $aux++;
568
             }
572
             }
582
                 guardar_log("Excel", "Escribir criterio evaluacion tecnica--" . $contador);
586
                 guardar_log("Excel", "Escribir criterio evaluacion tecnica--" . $contador);
583
                 $contador++;
587
                 $contador++;
584
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
588
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
585
-                $sheet->SetCellValue('B' . $aux, $datos['evaluationCriteriaTypeCode']);
589
+                $sheet->SetCellValue('B' . $aux, $datos['code_desc']);
586
                 $sheet->SetCellValue('C' . $aux, $datos['description']);
590
                 $sheet->SetCellValue('C' . $aux, $datos['description']);
587
                 $aux++;
591
                 $aux++;
588
             }
592
             }
603
                 guardar_log("Excel", "Escribir requisitos participacion--" . $contador);
607
                 guardar_log("Excel", "Escribir requisitos participacion--" . $contador);
604
                 $contador++;
608
                 $contador++;
605
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
609
                 $sheet->SetCellValue('A' . $aux, $datos['id_ajena_licitacion']);
606
-                $sheet->SetCellValue('B' . $aux, $datos['evaluationCriteriaTypeCode']);
610
+                $sheet->SetCellValue('B' . $aux, $datos['code_desc']);
607
                 $aux++;
611
                 $aux++;
608
             }
612
             }
609
 
613
 
697
         $spreadsheet->getActiveSheet()->SetCellValue('L1', "Tipo de contrato");
701
         $spreadsheet->getActiveSheet()->SetCellValue('L1', "Tipo de contrato");
698
         $spreadsheet->getActiveSheet()->SetCellValue('M1', "Lugar de ejecución");
702
         $spreadsheet->getActiveSheet()->SetCellValue('M1', "Lugar de ejecución");
699
         $spreadsheet->getActiveSheet()->SetCellValue('N1', "Órgano de Contratación");
703
         $spreadsheet->getActiveSheet()->SetCellValue('N1', "Órgano de Contratación");
700
-        $spreadsheet->getActiveSheet()->SetCellValue('O1', "ID OC en PLACSP");
701
-        $spreadsheet->getActiveSheet()->SetCellValue('P1', "NIF OC");
702
-        $spreadsheet->getActiveSheet()->SetCellValue('Q1', "DIR3");
703
-        $spreadsheet->getActiveSheet()->SetCellValue('R1', "Enlace al Perfil de Contratante del OC");
704
-        $spreadsheet->getActiveSheet()->SetCellValue('S1', "Tipo de Administración");
705
-        $spreadsheet->getActiveSheet()->SetCellValue('T1', "Código Postal");
706
-        $spreadsheet->getActiveSheet()->SetCellValue('U1', "Tipo de procedimiento");
707
-        $spreadsheet->getActiveSheet()->SetCellValue('V1', "Sistema de contratación");
708
-        $spreadsheet->getActiveSheet()->SetCellValue('W1', "Tramitación");
709
-        $spreadsheet->getActiveSheet()->SetCellValue('X1', "Forma de presentación de la oferta");
710
-        $spreadsheet->getActiveSheet()->SetCellValue('Y1', "Directiva de aplicación");
711
-        $spreadsheet->getActiveSheet()->SetCellValue('Z1', "Subcontratación permitida");
712
-        $spreadsheet->getActiveSheet()->SetCellValue('AA1', "Duración Contrato");
713
-        $spreadsheet->getActiveSheet()->SetCellValue('AB1', "Tipo de duración");
714
-        $spreadsheet->getActiveSheet()->SetCellValue('AC1', "Inicio contrato");
715
-        $spreadsheet->getActiveSheet()->SetCellValue('AD1', "Fin contrato");
716
-        $spreadsheet->getActiveSheet()->SetCellValue('AE1', "Extension Contrato");
717
-        $spreadsheet->getActiveSheet()->SetCellValue('AF1', "URL Organo Contratación");
718
-        $spreadsheet->getActiveSheet()->SetCellValue('AG1', "Ciudad Organo Contratación");
719
-        $spreadsheet->getActiveSheet()->SetCellValue('AH1', "Dirección Organo Contratación");
720
-        $spreadsheet->getActiveSheet()->SetCellValue('AI1', "Nombre Contacto Organo Contratación");
721
-        $spreadsheet->getActiveSheet()->SetCellValue('AJ1', "Email contacto Organo Contratación");
704
+        $spreadsheet->getActiveSheet()->SetCellValue('O1', "DIR3");
705
+        $spreadsheet->getActiveSheet()->SetCellValue('P1', "Enlace al Perfil de Contratante del OC");
706
+        $spreadsheet->getActiveSheet()->SetCellValue('Q1', "Tipo de Administración");
707
+        $spreadsheet->getActiveSheet()->SetCellValue('R1', "Código Postal");
708
+        $spreadsheet->getActiveSheet()->SetCellValue('S1', "Tipo de procedimiento");
709
+        $spreadsheet->getActiveSheet()->SetCellValue('T1', "Sistema de contratación");
710
+        $spreadsheet->getActiveSheet()->SetCellValue('U1', "Tramitación");
711
+        $spreadsheet->getActiveSheet()->SetCellValue('V1', "Forma de presentación de la oferta");
712
+        $spreadsheet->getActiveSheet()->SetCellValue('W1', "Directiva de aplicación");
713
+        $spreadsheet->getActiveSheet()->SetCellValue('X1', "Subcontratación permitida");
714
+        $spreadsheet->getActiveSheet()->SetCellValue('Y1', "Duración Contrato");
715
+        $spreadsheet->getActiveSheet()->SetCellValue('Z1', "Tipo de duración");
716
+        $spreadsheet->getActiveSheet()->SetCellValue('AA1', "Inicio contrato");
717
+        $spreadsheet->getActiveSheet()->SetCellValue('AB1', "Fin contrato");
718
+        $spreadsheet->getActiveSheet()->SetCellValue('AC1', "Extension Contrato");
719
+        $spreadsheet->getActiveSheet()->SetCellValue('AD1', "URL Organo Contratación");
720
+        $spreadsheet->getActiveSheet()->SetCellValue('AE1', "Ciudad Organo Contratación");
721
+        $spreadsheet->getActiveSheet()->SetCellValue('AF1', "Dirección Organo Contratación");
722
+        $spreadsheet->getActiveSheet()->SetCellValue('AG1', "Nombre Contacto Organo Contratación");
723
+        $spreadsheet->getActiveSheet()->SetCellValue('AH1', "Email contacto Organo Contratación");
722
         return $spreadsheet;
724
         return $spreadsheet;
723
     }
725
     }
724
 
726
 
759
         $spreadsheet->getActiveSheet()->SetCellValue('C1', "Número de lote");
761
         $spreadsheet->getActiveSheet()->SetCellValue('C1', "Número de lote");
760
         $spreadsheet->getActiveSheet()->SetCellValue('D1', "Importe sin Impuestos");
762
         $spreadsheet->getActiveSheet()->SetCellValue('D1', "Importe sin Impuestos");
761
         $spreadsheet->getActiveSheet()->SetCellValue('E1', "Lugar de ejecución del lote");
763
         $spreadsheet->getActiveSheet()->SetCellValue('E1', "Lugar de ejecución del lote");
762
-        $spreadsheet->getActiveSheet()->SetCellValue('E1', "CPV");
764
+        $spreadsheet->getActiveSheet()->SetCellValue('F1', "CPV");
763
 
765
 
764
         return $spreadsheet;
766
         return $spreadsheet;
765
     }
767
     }
826
         $spreadsheet->getActiveSheet()->SetCellValue('L1', 'Fecha de formalización');
828
         $spreadsheet->getActiveSheet()->SetCellValue('L1', 'Fecha de formalización');
827
         $spreadsheet->getActiveSheet()->SetCellValue('M1', 'Adjudicatario CIF');
829
         $spreadsheet->getActiveSheet()->SetCellValue('M1', 'Adjudicatario CIF');
828
         $spreadsheet->getActiveSheet()->SetCellValue('N1', 'Nombre Adjudicatario');
830
         $spreadsheet->getActiveSheet()->SetCellValue('N1', 'Nombre Adjudicatario');
829
-
831
+        $spreadsheet->getActiveSheet()->SetCellValue('O1', 'Importe de adjudicación sin impuestos');
830
         return $spreadsheet;
832
         return $spreadsheet;
831
     }
833
     }
832
 
834
 
895
         );
897
         );
896
         $sheet->getStyle("A1:C1")->applyFromArray($styleArr);
898
         $sheet->getStyle("A1:C1")->applyFromArray($styleArr);
897
         $spreadsheet->getActiveSheet()->SetCellValue('A1', 'Identificador');
899
         $spreadsheet->getActiveSheet()->SetCellValue('A1', 'Identificador');
898
-        $spreadsheet->getActiveSheet()->SetCellValue('B1', 'Tipo criterio de adjudicación');
899
-        $spreadsheet->getActiveSheet()->SetCellValue('C1', 'Descripción textual del criterio de adjudicación');
900
+        $spreadsheet->getActiveSheet()->SetCellValue('B1', 'Descripción textual del criterio de adjudicación');
901
+        $spreadsheet->getActiveSheet()->SetCellValue('C1', 'Ponderación');
900
 
902
 
901
         return $spreadsheet;
903
         return $spreadsheet;
902
     }
904
     }

+ 25 - 49
application/controllers/Parser.php View File

45
 
45
 
46
                     if ($this->newFolder($rutaPerfil . "/" . $fechaCarpeta)) {
46
                     if ($this->newFolder($rutaPerfil . "/" . $fechaCarpeta)) {
47
                         $this->rutaDiariaFecha = $rutaPerfil . "/" . $fechaCarpeta . "/";
47
                         $this->rutaDiariaFecha = $rutaPerfil . "/" . $fechaCarpeta . "/";
48
-
49
-                        //$this->downloadProcess($row->url_descarga);
50
                         $this->downloadZip($row->url_descarga);
48
                         $this->downloadZip($row->url_descarga);
51
                     }
49
                     }
52
 
50
 
75
     } */
73
     } */
76
     }
74
     }
77
 
75
 
78
-    private function downloadProcess($urlXML)
79
-    {
80
-
81
-        $fileName = basename($urlXML);
82
-        $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
83
-        $archivoAtom = $this->getFile($this->rutaDiariaFecha . $fileName, $fileName);
84
-        $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
85
-
86
-        while ($nuevoAtomAttrNext !== "") {
87
-            //$aux = 0;
88
-            //while ($aux <= 3) {
89
-
90
-            $fileName = basename($nuevoAtomAttrNext);
91
-            $this->downloadFile($fileName, $nuevoAtomAttrNext, $this->rutaDiariaFecha);
92
-            $archivoAtom = $this->getFile($this->rutaDiariaFecha . $fileName, $fileName);
93
-
94
-            $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
95
-            //$aux++;
96
-        }
97
-    }
98
-
99
     private function downloadZip($urlXML)
76
     private function downloadZip($urlXML)
100
     {
77
     {
78
+        $fechaDescarga = $this->getFechaForDownloadZip();
101
         $fileName = basename($urlXML);
79
         $fileName = basename($urlXML);
102
-        $downladedZip = $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
80
+        $downladedZip = $this->downloadFile($fileName, $urlXML . $fechaDescarga, $this->rutaDiariaFecha);
103
 
81
 
104
         if ($downladedZip) {
82
         if ($downladedZip) {
105
             $zip = new ZipArchive;
83
             $zip = new ZipArchive;
112
                 foreach ($archivosTotales as $file) {
90
                 foreach ($archivosTotales as $file) {
113
                     $this->getFile($this->rutaDiariaFecha . $file, $file);
91
                     $this->getFile($this->rutaDiariaFecha . $file, $file);
114
                 }
92
                 }
115
-
116
             }
93
             }
94
+        }
95
+    }
117
 
96
 
97
+    private function getFechaForDownloadZip(): String
98
+    {
99
+        $result = "_";
100
+        $anyo = date("Y");
101
+        $mes = date("m");
102
+        $mesPrevious = date("m", strtotime("-1 months"));
103
+        $yearPrevious = date("Y", strtotime("-1 year"));
104
+        $dia = date("d");
105
+
106
+        if (date("m") == "01") {
107
+            $result .= $yearPrevious . $mesPrevious . ".zip";
108
+        } else {
109
+            if ($dia == "01") {
110
+                $result .= $anyo . $mesPrevious . ".zip";
111
+            } else {
112
+                $result .= $anyo . $mes . ".zip";
113
+            }
118
         }
114
         }
115
+
116
+        return $result;
119
     }
117
     }
120
 
118
 
121
     private function getFile($url, $fileName)
119
     private function getFile($url, $fileName)
148
         file_put_contents($this->rutaDiariaFecha . "/format/" . $fileName, $closureFormat);
146
         file_put_contents($this->rutaDiariaFecha . "/format/" . $fileName, $closureFormat);
149
     }
147
     }
150
 
148
 
151
-    private function readNextAttribute($archivo)
152
-    {
153
-        $enlace = "";
154
-        foreach ($archivo['link'] as $row) {
155
-            $attrNext = $row['@attributes']['rel'];
156
-            $attrHref = $row['@attributes']['href'];
157
-
158
-            if ($attrNext === "next") {
159
-                if (!strpos($attrHref, "licitacionesPerfilesContratanteCompleto3_2021")) { //"20220127_")) {
160
-                    $enlace = $attrHref;
161
-                } else {
162
-                    $enlace = "";
163
-                }
164
-                //$enlace = $attrHref;
165
-            }
166
-        }
167
-
168
-        return $enlace;
169
-    }
170
-
171
     private function downloadFile($fileName, $url, $ruta)
149
     private function downloadFile($fileName, $url, $ruta)
172
     {
150
     {
173
         if (file_put_contents($ruta . $fileName, file_get_contents($url))) {
151
         if (file_put_contents($ruta . $fileName, file_get_contents($url))) {
179
 
157
 
180
     private function regExIniciosEsquema($xml)
158
     private function regExIniciosEsquema($xml)
181
     {
159
     {
182
-        $pattern = "/(<cac:)|(<cbc:)|(<cac-place-ext:)|(<cbc-place-ext:)/";
160
+        $pattern = "/(<cac:)|(<cbc:)|(<cac-place-ext:)|(<cbc-place-ext:)|(<at:)/";
183
         $result = preg_replace($pattern, "<", $xml);
161
         $result = preg_replace($pattern, "<", $xml);
184
 
162
 
185
         return $result;
163
         return $result;
187
 
165
 
188
     private function regExFinalesEsquema($xml)
166
     private function regExFinalesEsquema($xml)
189
     {
167
     {
190
-        $pattern = "/(<\/cac:)|(<\/cbc:)|(<\/cac-place-ext:)|(<\/cbc-place-ext:)/";
168
+        $pattern = "/(<\/cac:)|(<\/cbc:)|(<\/cac-place-ext:)|(<\/cbc-place-ext:)|(<\/at:)/";
191
         $result = preg_replace($pattern, "</", $xml);
169
         $result = preg_replace($pattern, "</", $xml);
192
 
170
 
193
         return $result;
171
         return $result;
195
 
173
 
196
     private function tablasCalculadas($idUltimaImportacion)
174
     private function tablasCalculadas($idUltimaImportacion)
197
     {
175
     {
198
-        $this->Parser_model->truncateTables("import_licitaciones_temp");
199
-
200
         $this->Parser_model->truncateTables("vista_datos_licitacion");
176
         $this->Parser_model->truncateTables("vista_datos_licitacion");
201
 
177
 
202
         $licitaciones = $this->Xlsexport_model->getLicitaciones($idUltimaImportacion);
178
         $licitaciones = $this->Xlsexport_model->getLicitaciones($idUltimaImportacion);

+ 198 - 0
application/controllers/ParserCompleto.php View File

1
+<?php
2
+defined('BASEPATH') or exit('No direct script access allowed');
3
+
4
+/**
5
+ *
6
+ * Controller ParserCompleto
7
+ *
8
+ * This controller for ...
9
+ *
10
+ * @package   CodeIgniter
11
+ * @category  Controller CI
12
+ * @author    Setiawan Jodi <jodisetiawan@fisip-untirta.ac.id>
13
+ * @author    Raul Guerrero <r.g.c@me.com>
14
+ * @link      https://github.com/setdjod/myci-extension/
15
+ * @param     ...
16
+ * @return    ...
17
+ *
18
+ */
19
+
20
+class ParserCompleto extends CI_Controller
21
+{
22
+
23
+    //TODO: PARAMETRIZAR BBDD -> SI EXISTE UN PROCESO EN MARCHA, NO INICIAR SIGUIENTE DESCARGA, AVISAR
24
+    protected $rutaDiaria = FCPATH . "DOWNLOADS/DAILY/";
25
+    protected $rutaDiariaFecha = "";
26
+
27
+    protected $rutaMensual = FCPATH . "DOWNLOADS/MONTH/";
28
+    protected $enlaceAtom = "";
29
+    protected $fechaCreacionLog = "";
30
+
31
+    public function __construct()
32
+    {
33
+        parent::__construct();
34
+        $this->load->helper('file');
35
+        $this->load->helper('xml');
36
+        $this->load->library('parserfile');
37
+
38
+        $this->load->model("Parser_model");
39
+    }
40
+
41
+    public function index()
42
+    {
43
+        $existCronRun = $this->Parser_model->existCronRun();
44
+        $fechaCarpeta = "";
45
+        if ($existCronRun['num_rows'] > 0) {
46
+            if ($existCronRun['datos']->cron_ejecucion == 0) {
47
+
48
+                $this->Parser_model->inicioParser();
49
+
50
+                $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
51
+                $fechaCarpeta = date("Y-m-d_H-i-s");
52
+                $fechaImportacionLog = date("Y-m-d H:i:s");
53
+
54
+                foreach ($resultSetPerfiles['datos'] as $row) {
55
+
56
+                    $idUltimaImportacion = $this->Parser_model->setFechaNuevaImportacion($fechaImportacionLog);
57
+                    $this->fechaCreacionLog = $fechaCarpeta;
58
+                    $rutaPerfil = $this->rutaDiaria . "/" . $row->prefijos_tablas;
59
+
60
+                    $this->newFolder($rutaPerfil);
61
+
62
+                    if ($this->newFolder($rutaPerfil . "/" . $fechaCarpeta)) {
63
+                        $this->rutaDiariaFecha = $rutaPerfil . "/" . $fechaCarpeta . "/";
64
+                        $this->downloadProcess($row->url_descarga . ".atom");
65
+                    }
66
+
67
+                    $files = get_filenames($this->rutaDiariaFecha . "/format");
68
+                    emailInicioProcesoDescarga($fechaImportacionLog, $files);
69
+
70
+                    $this->parserfile->index($this->rutaDiariaFecha, $fechaCarpeta, $row, $idUltimaImportacion);
71
+                }
72
+
73
+                $this->tablasCalculadas($idUltimaImportacion);
74
+
75
+                emailFinProcesoDescarga($fechaImportacionLog);
76
+
77
+            } else {
78
+                echo "EXISTE UN CRON EN MARCHA.";
79
+            }
80
+        } else {
81
+            echo "No existe parametro que iniciar.";
82
+        }
83
+
84
+        $this->Parser_model->stopParser();
85
+
86
+        /* $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
87
+    foreach ($resultSetPerfiles['datos'] as $row) {
88
+    $this->parserfile->index($this->rutaDiaria . "PER_PCSP_EX/2022-02-17_20-38-16", date("Y-m-d"), $row);
89
+    } */
90
+    }
91
+
92
+    private function downloadProcess($urlXML)
93
+    {
94
+
95
+        $fileName = basename($urlXML);
96
+        $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
97
+        $archivoAtom = $this->getFile($this->rutaDiariaFecha . $fileName, $fileName);
98
+        $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
99
+
100
+        while ($nuevoAtomAttrNext !== "") {
101
+
102
+            $fileName = basename($nuevoAtomAttrNext);
103
+            $this->downloadFile($fileName, $nuevoAtomAttrNext, $this->rutaDiariaFecha);
104
+            $archivoAtom = $this->getFile($this->rutaDiariaFecha . $fileName, $fileName);
105
+
106
+            $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
107
+        }
108
+    }
109
+
110
+    private function readNextAttribute($archivo)
111
+    {
112
+        $enlace = "";
113
+        foreach ($archivo['link'] as $row) {
114
+            $attrNext = $row['@attributes']['rel'];
115
+            $attrHref = $row['@attributes']['href'];
116
+
117
+            if ($attrNext === "next") {
118
+                if (!strpos($attrHref, "licitacionesPerfilesContratanteCompleto3_2021")) { //"20220127_")) {
119
+                    $enlace = $attrHref;
120
+                } else {
121
+                    $enlace = "";
122
+                }
123
+                //$enlace = $attrHref;
124
+            }
125
+        }
126
+
127
+        return $enlace;
128
+    }
129
+
130
+    private function getFile($url, $fileName)
131
+    {
132
+
133
+        $feed = implode(file($url));
134
+        $xml = simplexml_load_string($feed);
135
+        $json = json_encode($xml);
136
+        $array = json_decode($json, true);
137
+
138
+        $this->formatXml($feed, $fileName);
139
+        return $array;
140
+    }
141
+
142
+    private function newFolder($rutaFinal)
143
+    {
144
+        $result = false;
145
+        if (!is_dir($rutaFinal)) {
146
+            $result = mkdir($rutaFinal);
147
+            mkdir($rutaFinal . "/format");
148
+        }
149
+
150
+        return $result;
151
+    }
152
+
153
+    private function formatXml($xml, $fileName)
154
+    {
155
+        $openingFormat = $this->regExIniciosEsquema($xml);
156
+        $closureFormat = $this->regExFinalesEsquema($openingFormat);
157
+        file_put_contents($this->rutaDiariaFecha . "/format/" . $fileName, $closureFormat);
158
+    }
159
+
160
+    private function downloadFile($fileName, $url, $ruta)
161
+    {
162
+        if (file_put_contents($ruta . $fileName, file_get_contents($url))) {
163
+            return true;
164
+        } else {
165
+            return false;
166
+        }
167
+    }
168
+
169
+    private function regExIniciosEsquema($xml)
170
+    {
171
+        $pattern = "/(<cac:)|(<cbc:)|(<cac-place-ext:)|(<cbc-place-ext:)/";
172
+        $result = preg_replace($pattern, "<", $xml);
173
+
174
+        return $result;
175
+    }
176
+
177
+    private function regExFinalesEsquema($xml)
178
+    {
179
+        $pattern = "/(<\/cac:)|(<\/cbc:)|(<\/cac-place-ext:)|(<\/cbc-place-ext:)/";
180
+        $result = preg_replace($pattern, "</", $xml);
181
+
182
+        return $result;
183
+    }
184
+
185
+    private function tablasCalculadas($idUltimaImportacion)
186
+    {
187
+        $this->Parser_model->truncateTables("vista_datos_licitacion");
188
+
189
+        $licitaciones = $this->Xlsexport_model->getLicitaciones($idUltimaImportacion);
190
+
191
+        insertBucleDuplicateOnKey($licitaciones['datos'], "vista_datos_licitacion", "");
192
+
193
+    }
194
+
195
+}
196
+
197
+/* End of file ParserCompleto.php */
198
+/* Location: ./application/controllers/ParserCompleto.php */

+ 1 - 1
application/helpers/email_templates_helper.php View File

26
 		</html>";
26
 		</html>";
27
 
27
 
28
         $email = "chcalvoleon@mindden.com";
28
         $email = "chcalvoleon@mindden.com";
29
-        enviarEmail($asunto, $cuerpo, $email, false);
29
+        enviarEmail($asunto, $cuerpo, $email, true);
30
     }
30
     }
31
 }
31
 }
32
 
32
 

+ 4 - 8
application/helpers/funciones_helper.php View File

167
 
167
 
168
         $CI->load->library('email');
168
         $CI->load->library('email');
169
 
169
 
170
-        $config['protocol'] = 'smtp';
170
+        $config['protocol'] = 'mail';
171
         $config['smtp_host'] = 'smtp.gmail.com';
171
         $config['smtp_host'] = 'smtp.gmail.com';
172
         $config['smtp_user'] = 'chcalvoleon@mindden.com';
172
         $config['smtp_user'] = 'chcalvoleon@mindden.com';
173
         $config['smtp_pass'] = '4lb1R2014';
173
         $config['smtp_pass'] = '4lb1R2014';
174
         $config['smtp_crypto'] = 'ssl';
174
         $config['smtp_crypto'] = 'ssl';
175
-        $config['smtp_port'] = 465;
175
+        $config['smtp_port'] = 25;
176
         $config['mailtype'] = 'html';
176
         $config['mailtype'] = 'html';
177
         $config['wordwrap'] = 'TRUE';
177
         $config['wordwrap'] = 'TRUE';
178
         $config['newline'] = "\r\n";
178
         $config['newline'] = "\r\n";
188
         $CI->email->subject($asunto);
188
         $CI->email->subject($asunto);
189
         $CI->email->message($body);
189
         $CI->email->message($body);
190
 
190
 
191
-        foreach ($adjuntos as $row) {
192
-            $CI->email->attach($row);
193
-        }
194
-
195
         if ($print_result) {
191
         if ($print_result) {
196
-            $CI->email->send(false);
192
+            $CI->email->send(true);
197
             $CI->email->print_debugger();
193
             $CI->email->print_debugger();
198
         } else {
194
         } else {
199
-            $CI->email->send(false);
195
+            $CI->email->send(true);
200
         }
196
         }
201
     }
197
     }
202
 }
198
 }

+ 50 - 21
application/libraries/ParserFile.php View File

40
         $files = get_filenames($this->rutaDiaria, true);
40
         $files = get_filenames($this->rutaDiaria, true);
41
         $filename = "";
41
         $filename = "";
42
         $xml = "";
42
         $xml = "";
43
-        $json = "";
44
         $array = "";
43
         $array = "";
45
         $aux = 0;
44
         $aux = 0;
46
         $resultEntries = array();
45
         $resultEntries = array();
47
-        $contador = 0;
48
-
49
         $stats = array();
46
         $stats = array();
50
 
47
 
51
         foreach ($files as $file) {
48
         foreach ($files as $file) {
52
             $filename = basename($file);
49
             $filename = basename($file);
53
-            $contador++;
54
             $entrada = file_get_contents($file);
50
             $entrada = file_get_contents($file);
55
             $xml = simplexml_load_string($entrada, "SimpleXMLElement", LIBXML_NOCDATA);
51
             $xml = simplexml_load_string($entrada, "SimpleXMLElement", LIBXML_NOCDATA);
56
             $array = json_decode(json_encode($xml), true);
52
             $array = json_decode(json_encode($xml), true);
61
             foreach ($tablasTruncate['datos'] as $row) {
57
             foreach ($tablasTruncate['datos'] as $row) {
62
                 $this->CI->Parser_model->truncateTables($row->tabla_sucia);
58
                 $this->CI->Parser_model->truncateTables($row->tabla_sucia);
63
             }
59
             }
64
-
65
-            gc_mem_caches();
66
-            gc_collect_cycles();
60
+            $arrayDeletedEntries = array();
61
+            $arrayDeletedEntries = $array['deleted-entry'];
67
 
62
 
68
             foreach ($array['entry'] as $clave => $row) {
63
             foreach ($array['entry'] as $clave => $row) {
69
 
64
 
70
                 $existLicitacionActualizada = $this->getDatosLicitacion($row);
65
                 $existLicitacionActualizada = $this->getDatosLicitacion($row);
71
 
66
 
72
                 if (!$existLicitacionActualizada) {
67
                 if (!$existLicitacionActualizada) {
73
-                    //$arrayDeletedEntries = $xml->children('at', true);
74
 
68
 
75
-                    $resultEntries[$filename]['general'][$aux] = $this->nodoEntry($row, $xml->entry[$clave], $datosPerfil->id, $idUltimaImportacion);
69
+                    $resultEntries[$filename]['general'][$aux] = $this->nodoEntry($row, $xml->entry[$clave], $datosPerfil->id, $idUltimaImportacion, $arrayDeletedEntries);
76
 
70
 
77
                     $contractFolder = $this->nodoContractFolderStatus($row, $xml->entry[$clave]);
71
                     $contractFolder = $this->nodoContractFolderStatus($row, $xml->entry[$clave]);
78
 
72
 
179
         return $result;
173
         return $result;
180
     }
174
     }
181
 
175
 
182
-    private function nodoEntry($xml, $xmlPrimitivo, $tipoPerfil, $idUltimaImportacion)
176
+    private function nodoEntry($xml, $xmlPrimitivo, $tipoPerfil, $idUltimaImportacion, $deletedEntry)
183
     {
177
     {
184
         $resultEntries = array();
178
         $resultEntries = array();
185
         $id_licitacion = (string) substr($xml['id'], strrpos($xml['id'], '/') + 1);
179
         $id_licitacion = (string) substr($xml['id'], strrpos($xml['id'], '/') + 1);
193
         $resultEntries['tipo_perfil_licitacion'] = $tipoPerfil;
187
         $resultEntries['tipo_perfil_licitacion'] = $tipoPerfil;
194
         $resultEntries['fecha_creacion_log'] = $this->fechaInicioParser;
188
         $resultEntries['fecha_creacion_log'] = $this->fechaInicioParser;
195
         $resultEntries['id_importacion'] = $idUltimaImportacion;
189
         $resultEntries['id_importacion'] = $idUltimaImportacion;
190
+
191
+        $resultEntries['estadoLicitacion'] = "VIGENTE";
192
+        if ($deletedEntry) {
193
+            foreach ($deletedEntry as $row) {
194
+                $idBorrado = (string) substr($row['@attributes']["ref"], strrpos($row['@attributes']["ref"], '/') + 1);
195
+                if ($id_licitacion == $idBorrado) {
196
+                    $anyo1 = date_create($row['@attributes']['when']);
197
+                    $anyo2 = date_create($resultEntries['updated']);
198
+                    $diferencia = $anyo2->diff($anyo1);
199
+                    $diferenciaFormat = $diferencia->y;
200
+                    if ($diferenciaFormat > 5) {
201
+                        $resultEntries['estadoLicitacion'] = "ARCHIVADA";
202
+                    } else {
203
+                        $resultEntries['estadoLicitacion'] = "ANULADA";
204
+                    }
205
+                }
206
+            }
207
+
208
+        }
209
+
196
         return $resultEntries;
210
         return $resultEntries;
197
     }
211
     }
198
 
212
 
437
                 if (array_key_exists("AwardedTenderedProject", $tenderResult[$i])) {
451
                 if (array_key_exists("AwardedTenderedProject", $tenderResult[$i])) {
438
                     $awardedTenderedProject = $tenderResult[$i]['AwardedTenderedProject'];
452
                     $awardedTenderedProject = $tenderResult[$i]['AwardedTenderedProject'];
439
                     $resultEntries[$i]['procurementProjectLotID'] = $this->existNodo($awardedTenderedProject, 'ProcurementProjectLotID', 'string');
453
                     $resultEntries[$i]['procurementProjectLotID'] = $this->existNodo($awardedTenderedProject, 'ProcurementProjectLotID', 'string');
440
-                    $resultEntries[$i]['TaxExclusiveAmount'] = $this->existNodo($awardedTenderedProject->LegalMonetaryTotal, 'TaxExclusiveAmount', 'string');
441
-                    $resultEntries[$i]['PayableAmount'] = $this->existNodo($awardedTenderedProject->LegalMonetaryTotal, 'PayableAmount', 'string');
454
+                    $resultEntries[$i]['TaxExclusiveAmount'] = $this->existNodo($awardedTenderedProject['LegalMonetaryTotal'], 'TaxExclusiveAmount', 'string');
455
+                    $resultEntries[$i]['PayableAmount'] = $this->existNodo($awardedTenderedProject['LegalMonetaryTotal'], 'PayableAmount', 'string');
442
                 }
456
                 }
443
             }
457
             }
444
         }
458
         }
470
             $resultEntries['tenderingTerm']['procurementLegislationDocumentReference'] = $this->existNodo($TenderingTerms['ProcurementLegislationDocumentReference'], 'ID', 'string');
484
             $resultEntries['tenderingTerm']['procurementLegislationDocumentReference'] = $this->existNodo($TenderingTerms['ProcurementLegislationDocumentReference'], 'ID', 'string');
471
             $resultEntries['tenderingTerm']['allowedSubcontractTerms'] = $this->existNodo($TenderingTerms['AllowedSubcontractTerms'], 'Description', 'string');
485
             $resultEntries['tenderingTerm']['allowedSubcontractTerms'] = $this->existNodo($TenderingTerms['AllowedSubcontractTerms'], 'Description', 'string');
472
 
486
 
487
+            //Criterio de adjudicación
473
             if (array_key_exists("AwardingTerms", $TenderingTerms)) {
488
             if (array_key_exists("AwardingTerms", $TenderingTerms)) {
474
                 $tendererAwardingTerms = $TenderingTerms['AwardingTerms']['AwardingCriteria'];
489
                 $tendererAwardingTerms = $TenderingTerms['AwardingTerms']['AwardingCriteria'];
490
+                if (array_key_first($tendererAwardingTerms) !== 0) {
491
+                    $tendererAwardingTerms = array(0 => $tendererAwardingTerms);
492
+                }
475
                 for ($i = 0; $i < count($tendererAwardingTerms); $i++) {
493
                 for ($i = 0; $i < count($tendererAwardingTerms); $i++) {
476
-                    $resultEntries["awardingCriteria"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($tendererAwardingTerms[$i], 'Description', 'string');
477
-                    $resultEntries["awardingCriteria"][$i]['description'] = $this->existNodo($tendererAwardingTerms[$i], 'WeightNumeric', 'string');
494
+                    $resultEntries["awardingCriteria"][$i]['description'] = $this->existNodo($tendererAwardingTerms[$i], 'Description', 'string');
495
+                    $resultEntries["awardingCriteria"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($tendererAwardingTerms[$i], 'WeightNumeric', 'string');
478
                     $resultEntries["awardingCriteria"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
496
                     $resultEntries["awardingCriteria"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
479
                     $resultEntries["awardingCriteria"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
497
                     $resultEntries["awardingCriteria"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
480
                     $resultEntries["awardingCriteria"][$i]['id_compuesta_padre'] = $this->idLicitacion . "_07";
498
                     $resultEntries["awardingCriteria"][$i]['id_compuesta_padre'] = $this->idLicitacion . "_07";
482
                 }
500
                 }
483
             }
501
             }
484
 
502
 
503
+            //Criterio de evluación tecnica
485
             if (array_key_exists("TendererQualificationRequest", $TenderingTerms)) {
504
             if (array_key_exists("TendererQualificationRequest", $TenderingTerms)) {
486
                 $tendererQualificationRequest = $TenderingTerms['TendererQualificationRequest'];
505
                 $tendererQualificationRequest = $TenderingTerms['TendererQualificationRequest'];
487
                 $resultEntries['tenderingTerm']['description'] = $this->existNodo($tendererQualificationRequest, 'Description', 'string');
506
                 $resultEntries['tenderingTerm']['description'] = $this->existNodo($tendererQualificationRequest, 'Description', 'string');
488
                 $resultEntries['tenderingTerm']['personalSituation'] = $this->existNodo($tendererQualificationRequest, 'PersonalSituation', 'string');
507
                 $resultEntries['tenderingTerm']['personalSituation'] = $this->existNodo($tendererQualificationRequest, 'PersonalSituation', 'string');
489
-                for ($i = 0; $i < count($tendererQualificationRequest); $i++) {
490
-                    if (isset($tendererQualificationRequest[$i]['EvaluationCriteriaTypeCode'])) {
491
-                        $resultEntries["TendererQualificationRequest"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($tendererQualificationRequest[$i]['TechnicalEvaluationCriteria'], 'EvaluationCriteriaTypeCode', 'string');
492
-                        $resultEntries["TendererQualificationRequest"][$i]['evaluationCriteriaTypeCode_attr'] = $this->existAttribute($tendererQualificationRequest[$i]['TechnicalEvaluationCriteria'], "EvaluationCriteriaTypeCode", "sting", 'listURI');
493
-                        $resultEntries["TendererQualificationRequest"][$i]['description'] = $this->existNodo($tendererQualificationRequest[$i]['TechnicalEvaluationCriteria'], 'Description', 'string');
508
+                if (isset($tendererQualificationRequest['TechnicalEvaluationCriteria'])) {
509
+                    $techicnalQualifitacion = $tendererQualificationRequest['TechnicalEvaluationCriteria'];
510
+                    if (array_key_first($techicnalQualifitacion) !== 0) {
511
+                        $techicnalQualifitacion = array(0 => $techicnalQualifitacion);
512
+                    }
513
+                    for ($i = 0; $i < count($techicnalQualifitacion); $i++) {
514
+
515
+                        $resultEntries["TendererQualificationRequest"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($tendererQualificationRequest['TechnicalEvaluationCriteria'][$i], 'EvaluationCriteriaTypeCode', 'string');
516
+                        $resultEntries["TendererQualificationRequest"][$i]['evaluationCriteriaTypeCode_attr'] = $this->existAttribute($tendererQualificationRequest['TechnicalEvaluationCriteria'][$i], "EvaluationCriteriaTypeCode", "sting", 'listURI');
517
+                        $resultEntries["TendererQualificationRequest"][$i]['description'] = $this->existNodo($tendererQualificationRequest['TechnicalEvaluationCriteria'][$i], 'Description', 'string');
494
                         $resultEntries["TendererQualificationRequest"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
518
                         $resultEntries["TendererQualificationRequest"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
495
                         $resultEntries["TendererQualificationRequest"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
519
                         $resultEntries["TendererQualificationRequest"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
496
                         $resultEntries["TendererQualificationRequest"][$i]['id_compuesta_padre'] = $this->idLicitacion . "_07";
520
                         $resultEntries["TendererQualificationRequest"][$i]['id_compuesta_padre'] = $this->idLicitacion . "_07";
499
 
523
 
500
                 }
524
                 }
501
 
525
 
526
+                //Criterios de evaluacion financiera
502
                 if (array_key_exists("FinancialEvaluationCriteria", $TenderingTerms['TendererQualificationRequest'])) {
527
                 if (array_key_exists("FinancialEvaluationCriteria", $TenderingTerms['TendererQualificationRequest'])) {
503
                     $financialEvaluationCriteria = $TenderingTerms['TendererQualificationRequest']['FinancialEvaluationCriteria'];
528
                     $financialEvaluationCriteria = $TenderingTerms['TendererQualificationRequest']['FinancialEvaluationCriteria'];
504
                     for ($i = 0; $i < count($financialEvaluationCriteria); $i++) {
529
                     for ($i = 0; $i < count($financialEvaluationCriteria); $i++) {
512
                     }
537
                     }
513
                 }
538
                 }
514
 
539
 
540
+                //Requisitos de participación
515
                 if (array_key_exists("SpecificTendererRequirement", $TenderingTerms['TendererQualificationRequest'])) {
541
                 if (array_key_exists("SpecificTendererRequirement", $TenderingTerms['TendererQualificationRequest'])) {
516
                     $specificTendererRequirement = $TenderingTerms['TendererQualificationRequest']['SpecificTendererRequirement'];
542
                     $specificTendererRequirement = $TenderingTerms['TendererQualificationRequest']['SpecificTendererRequirement'];
543
+                    if (array_key_first($specificTendererRequirement) !== 0) {
544
+                        $specificTendererRequirement = array(0 => $specificTendererRequirement);
545
+                    }
517
                     for ($i = 0; $i < count($specificTendererRequirement); $i++) {
546
                     for ($i = 0; $i < count($specificTendererRequirement); $i++) {
518
 
547
 
519
-                        $resultEntries["SpecificTendererRequirement"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($specificTendererRequirement[$i]['SpecificTendererRequirement'], 'RequirementTypeCode', 'string');
520
-                        $resultEntries["SpecificTendererRequirement"][$i]['evaluationCriteriaTypeCode_attr'] = $this->existAttribute($specificTendererRequirement[$i]['SpecificTendererRequirement'], "RequirementTypeCode", "string", 'listURI');
548
+                        $resultEntries["SpecificTendererRequirement"][$i]['evaluationCriteriaTypeCode'] = $this->existNodo($specificTendererRequirement[$i], 'RequirementTypeCode', 'string');
549
+                        $resultEntries["SpecificTendererRequirement"][$i]['evaluationCriteriaTypeCode_attr'] = $this->existAttribute($specificTendererRequirement[$i], "RequirementTypeCode", "string", 'listURI');
521
                         $resultEntries["SpecificTendererRequirement"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
550
                         $resultEntries["SpecificTendererRequirement"][$i]['id_ajena_licitacion'] = $this->idLicitacion;
522
                         $resultEntries["SpecificTendererRequirement"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
551
                         $resultEntries["SpecificTendererRequirement"][$i]['id_compuesta'] = $this->idLicitacion . "_07_" . $i;
523
                         $resultEntries["SpecificTendererRequirement"][$i]['id_compuesta_padre'] = $this->idLicitacion . "_07";
552
                         $resultEntries["SpecificTendererRequirement"][$i]['id_compuesta_padre'] = $this->idLicitacion . "_07";

+ 1 - 1
application/models/Parser_model.php View File

62
 
62
 
63
     public function getUrlArchivos()
63
     public function getUrlArchivos()
64
     {
64
     {
65
-        $sql = "SELECT * FROM config_tipo_licitacion_tablas";
65
+        $sql = "SELECT * FROM config_tipo_licitacion_tablas WHERE activo = 1";
66
         $result = $this->db->query($sql);
66
         $result = $this->db->query($sql);
67
         $datos['datos'] = $result->result();
67
         $datos['datos'] = $result->result();
68
         $datos['num_rows'] = $result->num_rows();
68
         $datos['num_rows'] = $result->num_rows();

+ 11 - 1
application/models/Xlsexport_model.php View File

19
 class Xlsexport_model extends CI_Model
19
 class Xlsexport_model extends CI_Model
20
 {
20
 {
21
 
21
 
22
-    protected $fechaLog = "2022-02-28 08:42:06";
22
+    protected $fechaLog = "";
23
 
23
 
24
     public function __construct()
24
     public function __construct()
25
     {
25
     {
26
         parent::__construct();
26
         parent::__construct();
27
+        $this->fechaLog = $this->getLastDateLog()->fecha_maxima;
28
+    }
29
+
30
+    public function getLastDateLog()
31
+    {
32
+        $sql = "SELECT MAX(fecha) as fecha_maxima FROM config_fecha_importaciones LIMIT 1";
33
+        $result = $this->db->query($sql);
34
+        return $result->row();
35
+
27
     }
36
     }
28
 
37
 
29
     // ------------------------------------------------------------------------
38
     // ------------------------------------------------------------------------
37
                     GROUP_CONCAT( PROJI.itemClassification_value ) AS itemClassification_attr,
46
                     GROUP_CONCAT( PROJI.itemClassification_value ) AS itemClassification_attr,
38
                     LI.link_uri,
47
                     LI.link_uri,
39
                     LI.updated,
48
                     LI.updated,
49
+                    LI.estadoLicitacion,
40
                     CF.contractFolderID,
50
                     CF.contractFolderID,
41
                     CF.contractFolderStatusCode,
51
                     CF.contractFolderStatusCode,
42
                     LP.buyerProfileURIID,
52
                     LP.buyerProfileURIID,