123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- defined('BASEPATH') or exit('No direct script access allowed');
-
- /**
- *
- * Controller ExportXls
- *
- * This controller for ...
- *
- * @package CodeIgniter
- * @category Controller CI
- * @author Setiawan Jodi <jodisetiawan@fisip-untirta.ac.id>
- * @author Raul Guerrero <r.g.c@me.com>
- * @link https://github.com/setdjod/myci-extension/
- * @param ...
- * @return ...
- *
- */
-
- class ExportXls extends CI_Controller
- {
-
- public function __construct()
- {
- parent::__construct();
- $this->load->library('excel');
- $this->load->model("Xlsexport_model");
- }
-
- public function exportOpenPlacsp()
- {
- $objPHPExcel = new PHPExcel();
- // El libro activo el cual exportar sera el 0
- $objPHPExcel->setActiveSheetIndex(0);
- //Fila donde dibujar en el excel
- $rowCount = 1;
-
- $inventarioExport = $this->Xlsexport_model->getInventarioSinControladosUl($idInventario);
- foreach ($inventarioExport as $row) {
-
- //Escribimos las cabeceras de cada columna de la bbdd
- if ($rowCount == 1) {
- $this->cabecerasOpenPlacspFirstSheet($objPHPExcel);
- $concesionNombre = $row->concesionNombre;
- $codConc = $row->codConc;
- $rowCount++;
- }
- // Set cell An to the "name" column from the database (assuming you have a column called name)
- // where n is the Excel row number (ie cell A1 in the first row)
- $objPHPExcel->getActiveSheet()->SetCellValueExplicit('A' . $rowCount, $row->matricula);
- $objPHPExcel->getActiveSheet()->SetCellValueExplicit('B' . $rowCount, $row->codCliente10);
- $objPHPExcel->getActiveSheet()->SetCellValue('C' . $rowCount, $row->nombre_cliente);
- $objPHPExcel->getActiveSheet()->SetCellValue('D' . $rowCount, $row->direccion_del_cliente);
- $objPHPExcel->getActiveSheet()->SetCellValue('E' . $rowCount, $row->codigo_postal_del_cliente);
- $objPHPExcel->getActiveSheet()->SetCellValue('F' . $rowCount, $row->poblacion_del_cliente);
- $objPHPExcel->getActiveSheet()->SetCellValue('G' . $rowCount, $row->tipo_medio);
- $objPHPExcel->getActiveSheet()->SetCellValue('H' . $rowCount, $row->valor_alto);
- $objPHPExcel->getActiveSheet()->SetCellValue('I' . $rowCount, $row->valor_bajo);
- $objPHPExcel->getActiveSheet()->SetCellValue('J' . $rowCount, $row->ultimo_mov);
- $objPHPExcel->getActiveSheet()->SetCellValue('K' . $rowCount, $row->lectura_conc);
- $objPHPExcel->getActiveSheet()->SetCellValue('L' . $rowCount, $row->control_alm_com);
- $objPHPExcel->getActiveSheet()->SetCellValue('M' . $rowCount, $row->fecha_control);
- $objPHPExcel->getActiveSheet()->SetCellValue('N' . $rowCount, $row->estado_con);
- $objPHPExcel->getActiveSheet()->SetCellValue('O' . $rowCount, $row->estado_ul);
- $objPHPExcel->getActiveSheet()->SetCellValue('P' . $rowCount, $row->fecha_historico);
- $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $rowCount, $row->usuario_cambio);
-
- // Increment the Excel row counter
- $rowCount++;
- }
- $nombreAchivo = $codConc . ' - ' . $concesionNombre . ' - ' . date("Y-m-d") . '.xlsx';
-
- $ruta = base_url() . 'uploads/inventarios/' . $nombreAchivo;
-
- // Write the Excel file to filename some_excel_file.xlsx in the current directory
- // Redirect output to a client’s web browser (Excel5)
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Disposition: attachment;filename=' . $nombreAchivo . '');
- header('Pragma: cache');
- header('Cache-Control: private');
- $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
- $objWriter->save(FCPATH . 'uploads/inventarios/' . $nombreAchivo);
-
- $this->output
- ->set_content_type('application/json')
- ->set_output(json_encode(array("url" => $ruta)));
- }
-
- private function cabecerasOpenPlacspFirstSheet($objPHPExcel)
- {
- $objPHPExcel->getActiveSheet()->SetCellValue('A1', "Identificador");
- $objPHPExcel->getActiveSheet()->SetCellValue('B1', "Link licitación");
- $objPHPExcel->getActiveSheet()->SetCellValue('C1', "Fecha actualización");
- $objPHPExcel->getActiveSheet()->SetCellValue('D1', "Vigente/Anulada/Archivada");
- $objPHPExcel->getActiveSheet()->SetCellValue('E1', "Primera publicación");
- $objPHPExcel->getActiveSheet()->SetCellValue('F1', "Estado");
- $objPHPExcel->getActiveSheet()->SetCellValue('G1', "Número de expediente");
- $objPHPExcel->getActiveSheet()->SetCellValue('H1', "Objeto del Contrato");
- $objPHPExcel->getActiveSheet()->SetCellValue('I1', "Valor estimado del contrato");
- $objPHPExcel->getActiveSheet()->SetCellValue('J1', "Presupuesto base sin impuestos");
- $objPHPExcel->getActiveSheet()->SetCellValue('K1', "Presupuesto base con impuestos");
- $objPHPExcel->getActiveSheet()->SetCellValue('L1', "CPV");
- $objPHPExcel->getActiveSheet()->SetCellValue('M1', "Tipo de contrato");
- $objPHPExcel->getActiveSheet()->SetCellValue('N1', "Lugar de ejecución");
- $objPHPExcel->getActiveSheet()->SetCellValue('O1', "Órgano de Contratación");
- $objPHPExcel->getActiveSheet()->SetCellValue('P1', "ID OC en PLACSP");
- $objPHPExcel->getActiveSheet()->SetCellValue('Q1', "NIF OC");
- $objPHPExcel->getActiveSheet()->SetCellValue('R1', "DIR3");
- $objPHPExcel->getActiveSheet()->SetCellValue('S1', "Enlace al Perfil de Contratante del OC");
- $objPHPExcel->getActiveSheet()->SetCellValue('T1', "Tipo de Administración");
- $objPHPExcel->getActiveSheet()->SetCellValue('U1', "Código Postal");
- $objPHPExcel->getActiveSheet()->SetCellValue('V1', "Tipo de procedimiento");
- $objPHPExcel->getActiveSheet()->SetCellValue('W1', "Sistema de contratación");
- $objPHPExcel->getActiveSheet()->SetCellValue('X1', "Tramitación");
- $objPHPExcel->getActiveSheet()->SetCellValue('Y1', "Forma de presentación de la oferta");
- $objPHPExcel->getActiveSheet()->SetCellValue('Z1', "Directiva de aplicación");
- $objPHPExcel->getActiveSheet()->SetCellValue('AA1', "Subcontratación permitida");
- $objPHPExcel->getActiveSheet()->SetCellValue('AB1', "Subcontratación permitida porcentaje");
- return $objPHPExcel;
- }
- }
-
- /* End of file ExportXls.php */
- /* Location: ./application/controllers/ExportXls.php */
|