|
@@ -27,50 +27,82 @@ class ExportXls extends CI_Controller
|
27
|
27
|
$this->load->model("Xlsexport_model");
|
28
|
28
|
}
|
29
|
29
|
|
30
|
|
- public function exportOpenPlacsp()
|
|
30
|
+ public function exportDatosCompletos()
|
31
|
31
|
{
|
|
32
|
+ $licitacionesResult = $this->Xlsexport_model->getLicitaciones();
|
|
33
|
+ $result = array();
|
|
34
|
+
|
|
35
|
+ //$start = $this->starttime();
|
|
36
|
+ if ($licitacionesResult['num_rows'] > 0) {
|
|
37
|
+ foreach ($licitacionesResult['datos'] as $licitacion) {
|
|
38
|
+ $result[$licitacion->id]['licitacion'] = $licitacion;
|
|
39
|
+ $result[$licitacion->id]['contract'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_contract_folder", $licitacion->id);
|
|
40
|
+ $result[$licitacion->id]['locatedParty'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_located_contracting_party", $licitacion->id);
|
|
41
|
+ $result[$licitacion->id]['party'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_party", $licitacion->id);
|
|
42
|
+ foreach ($result[$licitacion->id]['party'] as $row) {
|
|
43
|
+ $result[$licitacion->id]['partyActivity'] = $this->Xlsexport_model->getDatosRelacionadosByTablaAndLicitacion("maestro_party_party_idenfitication", "id_ajena_party", $row['id']);
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ $result[$licitacion->id]['project'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_procurement_project", $licitacion->id);
|
|
47
|
+ foreach ($result[$licitacion->id]['project'] as $row) {
|
|
48
|
+ $result[$licitacion->id]['projectActivity'] = $this->Xlsexport_model->getDatosRelacionadosByTablaAndLicitacion("maestro_procurement_project_itemClass", "id_ajena_pp", $row['id']);
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ $result[$licitacion->id]['projectLot'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_procurement_project_lot", $licitacion->id);
|
|
52
|
+ foreach ($result[$licitacion->id]['projectLot'] as $row) {
|
|
53
|
+ $result[$licitacion->id]['projectLotActivity'] = $this->Xlsexport_model->getDatosRelacionadosByTablaAndLicitacion("maestro_procurement_project_lot_item", "id_ajena_ppl", $row['id']);
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ $result[$licitacion->id]['tenderResult'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_tender_result", $licitacion->id);
|
|
57
|
+ $result[$licitacion->id]['tenderProcess'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_tendering_process", $licitacion->id);
|
|
58
|
+ $result[$licitacion->id]['tenderTerms'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_tendering_terms", $licitacion->id);
|
|
59
|
+ foreach ($result[$licitacion->id]['tenderTerms'] as $row) {
|
|
60
|
+ $result[$licitacion->id]['tenderTermsAwarding'] = $this->Xlsexport_model->getDatosRelacionadosByTablaAndLicitacion("maestro_tendering_terms_awarding_terms", "id_ajena_tt", $row['id']);
|
|
61
|
+ $result[$licitacion->id]['tenderTermsFinancial'] = $this->Xlsexport_model->getDatosRelacionadosByTablaAndLicitacion("maestro_tendering_terms_financial_evaluation", "id_ajena_ttfe", $row['id']);
|
|
62
|
+ $result[$licitacion->id]['tenderTermsQualification'] = $this->Xlsexport_model->getDatosRelacionadosByTablaAndLicitacion("maestro_tendering_terms_qualification_request", "id_ajena_tt", $row['id']);
|
|
63
|
+ $result[$licitacion->id]['tenderTermsSpecific'] = $this->Xlsexport_model->getDatosRelacionadosByTablaAndLicitacion("maestro_tendering_terms_specific_terms", "id_ajena_tt", $row['id']);
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ $result[$licitacion->id]['validNoticeInfo'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_valid_notice_info", $licitacion->id);
|
|
67
|
+ foreach ($result[$licitacion->id]['validNoticeInfo'] as $row) {
|
|
68
|
+ $result[$licitacion->id]['validNoticeInfoDocument'] = $this->Xlsexport_model->getDatosRelacionadosByTablaAndLicitacion("maestro_valid_notice_info_documento", "id_ajena_vni", $row['id']);
|
|
69
|
+ $result[$licitacion->id]['validNoticeInfoFecha'] = $this->Xlsexport_model->getDatosRelacionadosByTablaAndLicitacion("maestro_valid_notice_info_fecha", "id_ajena_vni", $row['id']);
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ $result[$licitacion->id]['techDocs'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_technical_documents", $licitacion->id);
|
|
73
|
+ $result[$licitacion->id]['legalDocs'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_legal_documents", $licitacion->id);
|
|
74
|
+ $result[$licitacion->id]['generalDocs'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_general_documents", $licitacion->id);
|
|
75
|
+ $result[$licitacion->id]['additDocs'] = $this->Xlsexport_model->getDatosByTablaAndLicitacion("maestro_additional_documents", $licitacion->id);
|
|
76
|
+ }
|
|
77
|
+ }
|
|
78
|
+ //echo ($this->endtime($start));
|
|
79
|
+ //pretty_dump($result);
|
|
80
|
+
|
32
|
81
|
$objPHPExcel = new PHPExcel();
|
33
|
82
|
// El libro activo el cual exportar sera el 0
|
34
|
|
- $objPHPExcel->setActiveSheetIndex(0);
|
35
|
|
- //Fila donde dibujar en el excel
|
36
|
|
- $rowCount = 1;
|
37
|
|
-
|
38
|
|
- $inventarioExport = $this->Xlsexport_model->getInventarioSinControladosUl($idInventario);
|
39
|
|
- foreach ($inventarioExport as $row) {
|
40
|
|
-
|
41
|
|
- //Escribimos las cabeceras de cada columna de la bbdd
|
42
|
|
- if ($rowCount == 1) {
|
43
|
|
- $this->cabecerasOpenPlacspFirstSheet($objPHPExcel);
|
44
|
|
- $concesionNombre = $row->concesionNombre;
|
45
|
|
- $codConc = $row->codConc;
|
46
|
|
- $rowCount++;
|
|
83
|
+
|
|
84
|
+ $filaExcel = 1;
|
|
85
|
+ foreach ($result as $dato) {
|
|
86
|
+ if ($filaExcel == 1) {
|
|
87
|
+ $objPHPExcel = $this->cabecerasOpenPlacspFirstSheet($objPHPExcel);
|
|
88
|
+ } else {
|
|
89
|
+ $objPHPExcel = $this->datosCompletosHojaLicitacion($objPHPExcel, $dato, $filaExcel);
|
47
|
90
|
}
|
48
|
|
- // Set cell An to the "name" column from the database (assuming you have a column called name)
|
49
|
|
- // where n is the Excel row number (ie cell A1 in the first row)
|
50
|
|
- $objPHPExcel->getActiveSheet()->SetCellValueExplicit('A' . $rowCount, $row->matricula);
|
51
|
|
- $objPHPExcel->getActiveSheet()->SetCellValueExplicit('B' . $rowCount, $row->codCliente10);
|
52
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('C' . $rowCount, $row->nombre_cliente);
|
53
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('D' . $rowCount, $row->direccion_del_cliente);
|
54
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('E' . $rowCount, $row->codigo_postal_del_cliente);
|
55
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('F' . $rowCount, $row->poblacion_del_cliente);
|
56
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('G' . $rowCount, $row->tipo_medio);
|
57
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('H' . $rowCount, $row->valor_alto);
|
58
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('I' . $rowCount, $row->valor_bajo);
|
59
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('J' . $rowCount, $row->ultimo_mov);
|
60
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('K' . $rowCount, $row->lectura_conc);
|
61
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('L' . $rowCount, $row->control_alm_com);
|
62
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('M' . $rowCount, $row->fecha_control);
|
63
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('N' . $rowCount, $row->estado_con);
|
64
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('O' . $rowCount, $row->estado_ul);
|
65
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('P' . $rowCount, $row->fecha_historico);
|
66
|
|
- $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $rowCount, $row->usuario_cambio);
|
67
|
|
-
|
68
|
|
- // Increment the Excel row counter
|
69
|
|
- $rowCount++;
|
|
91
|
+
|
|
92
|
+ $filaExcel++;
|
70
|
93
|
}
|
71
|
|
- $nombreAchivo = $codConc . ' - ' . $concesionNombre . ' - ' . date("Y-m-d") . '.xlsx';
|
72
|
94
|
|
73
|
|
- $ruta = base_url() . 'uploads/inventarios/' . $nombreAchivo;
|
|
95
|
+/* //Escribimos las cabeceras de cada columna de la bbdd
|
|
96
|
+if ($rowCount == 1) {
|
|
97
|
+$this->cabecerasOpenPlacspFirstSheet($objPHPExcel);
|
|
98
|
+$concesionNombre = $row->concesionNombre;
|
|
99
|
+$codConc = $row->codConc;
|
|
100
|
+$rowCount++;
|
|
101
|
+}
|
|
102
|
+ */
|
|
103
|
+ $nombreAchivo = 'test.xls';
|
|
104
|
+
|
|
105
|
+ $ruta = base_url() . 'uploads/' . $nombreAchivo;
|
74
|
106
|
|
75
|
107
|
// Write the Excel file to filename some_excel_file.xlsx in the current directory
|
76
|
108
|
// Redirect output to a client’s web browser (Excel5)
|
|
@@ -79,13 +111,110 @@ class ExportXls extends CI_Controller
|
79
|
111
|
header('Pragma: cache');
|
80
|
112
|
header('Cache-Control: private');
|
81
|
113
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
82
|
|
- $objWriter->save(FCPATH . 'uploads/inventarios/' . $nombreAchivo);
|
|
114
|
+ $objWriter->save(FCPATH . 'uploads/' . $nombreAchivo);
|
83
|
115
|
|
84
|
116
|
$this->output
|
85
|
117
|
->set_content_type('application/json')
|
86
|
118
|
->set_output(json_encode(array("url" => $ruta)));
|
87
|
119
|
}
|
88
|
120
|
|
|
121
|
+ public function starttime()
|
|
122
|
+ {
|
|
123
|
+ $r = explode(' ', microtime());
|
|
124
|
+ $r = $r[1] + $r[0];
|
|
125
|
+ return $r;
|
|
126
|
+ }
|
|
127
|
+
|
|
128
|
+ public function endtime($starttime)
|
|
129
|
+ {
|
|
130
|
+ $r = explode(' ', microtime());
|
|
131
|
+ $r = $r[1] + $r[0];
|
|
132
|
+ $r = round($r - $starttime, 4);
|
|
133
|
+ return '<strong>Execution Time</strong>: ' . $r . ' seconds<br />';
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ private function datosCompletosHojaLicitacion($objPHPExcel, $datosLicitacion, $filaExcel)
|
|
137
|
+ {
|
|
138
|
+ $objPHPExcel->setActiveSheetIndex(0);
|
|
139
|
+ $styleArr = array(
|
|
140
|
+ "font" => array(
|
|
141
|
+ "bold" => true,
|
|
142
|
+ "color" => array("rgb" => "22B9FF"),
|
|
143
|
+ "size" => 13,
|
|
144
|
+ ),
|
|
145
|
+ );
|
|
146
|
+ $objPHPExcel->getActiveSheet()->getStyle("A1:AB1")->applyFromArray($styleArr);
|
|
147
|
+ //$sharedStyle1->applyFromArray(array('fill' => array('type' => \PHPExcel\Style\Fill::FILL_SOLID, 'color' => array('argb' => 'FFCCFFCC')), 'borders' => array('bottom' => array('style' => \PHPExcel\Style\Border::BORDER_THIN), 'right' => array('style' => \PHPExcel\Style\Border::BORDER_MEDIUM))));
|
|
148
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('A' . $filaExcel, $datosLicitacion['licitacion']->id_licitacion);
|
|
149
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('B' . $filaExcel, $datosLicitacion['licitacion']->url_id_licitacion);
|
|
150
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('C' . $filaExcel, $datosLicitacion['licitacion']->updated);
|
|
151
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('D' . $filaExcel, "");
|
|
152
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('E' . $filaExcel, "Primera publicación");
|
|
153
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('F' . $filaExcel, $datosLicitacion['contract'][0]['contractFolderStatusCode']);
|
|
154
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('G' . $filaExcel, $datosLicitacion['contract'][0]['contractFolderID']);
|
|
155
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('H' . $filaExcel, $datosLicitacion['project'][0]['name']);
|
|
156
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('I' . $filaExcel, $datosLicitacion['project'][0]['estimatedOverallContractAmount']);
|
|
157
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('J' . $filaExcel, $datosLicitacion['project'][0]['taxExclusiveAmount']);
|
|
158
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('K' . $filaExcel, $datosLicitacion['project'][0]['totalAmount']);
|
|
159
|
+
|
|
160
|
+ $cpvProject = "";
|
|
161
|
+ for ($i = 0; $i < count($datosLicitacion['projectActivity']); $i++) {
|
|
162
|
+ $cpvProject .= $datosLicitacion['projectActivity'][$i]['itemClassification_value'] . ";";
|
|
163
|
+ }
|
|
164
|
+
|
|
165
|
+ $cpvParty = "";
|
|
166
|
+ //TODO OBtener solo el DIR3
|
|
167
|
+ for ($i = 0; $i < count($datosLicitacion['partyActivity']); $i++) {
|
|
168
|
+ $cpvParty .= $datosLicitacion['partyActivity'][$i]['idPartyIdent'] . ";";
|
|
169
|
+ }
|
|
170
|
+
|
|
171
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('L' . $filaExcel, $cpvProject);
|
|
172
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('M' . $filaExcel, $datosLicitacion['project'][0]['typeCode']);
|
|
173
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('N' . $filaExcel, $datosLicitacion['project'][0]['countrySubentityCode'] . " - " . $datosLicitacion['project'][0]['countrySubentity']);
|
|
174
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('O' . $filaExcel, $datosLicitacion['party'][0]['partyName']);
|
|
175
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('P' . $filaExcel, $datosLicitacion['party'][0]['partyName']);
|
|
176
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $filaExcel, $datosLicitacion['locatedParty'][0]['contractingPartyTypeCode']);
|
|
177
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('R' . $filaExcel, $cpvParty);
|
|
178
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('S' . $filaExcel, $datosLicitacion['locatedParty'][0]['buyerProfileURIID']);
|
|
179
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('T' . $filaExcel, $datosLicitacion['locatedParty'][0]['contractingPartyTypeCode']);
|
|
180
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('U' . $filaExcel, $datosLicitacion['party'][0]['codpostal']);
|
|
181
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('V' . $filaExcel, $datosLicitacion['tenderProcess'][0]['procedureCode']);
|
|
182
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('W' . $filaExcel, $datosLicitacion['tenderProcess'][0]['contractingSystemCode']);
|
|
183
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('X' . $filaExcel, $datosLicitacion['tenderProcess'][0]['urgencyCode']);
|
|
184
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('Y' . $filaExcel, $datosLicitacion['tenderProcess'][0]['submissionMethodCode']);
|
|
185
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('Z' . $filaExcel, $datosLicitacion['tenderTerms'][0]['procurementLegislationDocumentReference']);
|
|
186
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('AA' . $filaExcel, $datosLicitacion['tenderTerms'][0]['allowedSubcontractTerms']);
|
|
187
|
+ $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $filaExcel, "");
|
|
188
|
+
|
|
189
|
+ return $objPHPExcel;
|
|
190
|
+
|
|
191
|
+ }
|
|
192
|
+
|
|
193
|
+ private function datosCompletosHojaBitacora($objPHPExcel, $datosLicitacion)
|
|
194
|
+ {
|
|
195
|
+
|
|
196
|
+ }
|
|
197
|
+
|
|
198
|
+ private function datosCompletosDocumentosGenerales($objPHPExcel)
|
|
199
|
+ {
|
|
200
|
+
|
|
201
|
+ }
|
|
202
|
+
|
|
203
|
+ private function datosCompletosDocumentosAdicionales($objPHPExcel)
|
|
204
|
+ {
|
|
205
|
+
|
|
206
|
+ }
|
|
207
|
+
|
|
208
|
+ private function datosCompletosDocumentosTecnicos($objPHPExcel)
|
|
209
|
+ {
|
|
210
|
+
|
|
211
|
+ }
|
|
212
|
+
|
|
213
|
+ private function datosCompletosDocumentosLegales($objPHPExcel)
|
|
214
|
+ {
|
|
215
|
+
|
|
216
|
+ }
|
|
217
|
+
|
89
|
218
|
private function cabecerasOpenPlacspFirstSheet($objPHPExcel)
|
90
|
219
|
{
|
91
|
220
|
$objPHPExcel->getActiveSheet()->SetCellValue('A1', "Identificador");
|