/** * Returns the geocoded map as a kmz string * @access public */ public function saveToString($title, $fileFormat = "kmz") { $box = $this->getKmlLatLonBox($this->getPixelImageCorners(), $this->projectionOrigin, $this->inverseTransformationMatrix); $kml = new KmlDocument(); $kml->title = $title; $kml->north = $box->north; $kml->south = $box->south; $kml->west = $box->west; $kml->east = $box->east; $kml->rotation = $box->rotation; if (strtolower($fileFormat) == "kml") { $kml->imageFileName = $this->imageUrl != null ? $this->imageUrl : $this->imageFileName; return $kml->saveToString(); } else { $kml->imageFileName = $this->getImageFileNameInKml(); $kmlString = $kml->saveToString(); $zip = new Zipfile(); $zip->addString($kmlString, "doc.kml"); $zip->addFile($this->imageFileName, $this->getImageFileNameInKml()); return $zip->saveToString(); } }
public function postBandejaexcel() { $gestion = Gestion::getCargar(); if (Input::has('imagen')) { $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("Jorge Salcedo")->setLastModifiedBy("Jorge Salcedo")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Reporte de Problemas")->setKeywords("office 2007 openxml php")->setCategory("Test result file"); $az = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ', 'CA', 'CB', 'CC', 'CD', 'CE', 'CF', 'CG', 'CH', 'CI', 'CJ', 'CK', 'CL', 'CM', 'CN', 'CO', 'CP', 'CQ', 'CR', 'CS', 'CT', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DA', 'DB', 'DC', 'DD', 'DE', 'DF', 'DG', 'DH', 'DI', 'DJ', 'DK', 'DL', 'DM', 'DN', 'DO', 'DP', 'DQ', 'DR', 'DS', 'DT', 'DU', 'DV', 'DW', 'DX', 'DY', 'DZ'); $objPHPExcel->getDefaultStyle()->getFont()->setName('Bookman Old Style'); $objPHPExcel->getDefaultStyle()->getFont()->setSize(8); $valorinicial = 1; $azpos = 0; foreach ($gestion['datos'] as $data) { //Encabezado if ($valorinicial == 1) { foreach ($data as $key => $val) { $objPHPExcel->getActiveSheet()->setCellValue($az[$azpos] . $valorinicial, $key); $azpos++; } } $valorinicial++; $azpos = 0; //Datos foreach ($data as $val) { $val = str_replace(array("\r\n", "\n", "\n\n", "\t", "\r"), array("", "", "", "", ""), $val); $objPHPExcel->getActiveSheet()->setCellValue($az[$azpos] . $valorinicial, $val); $azpos++; } } $objPHPExcel->getActiveSheet()->setTitle('PSI'); $objPHPExcel->setActiveSheetIndex(0); $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); $objWriter->save('reporte/u743/PSI_' . date("Y-m-d_H-i-s") . '.xlsx'); $zipfile = new Zipfile(); $zipfile->add_dir("reporte/"); $ruta = "reporte/u743/"; $zipfile->carpeta = array(); $zipfile->archivo = array(); $zipfile->listar_directorios_ruta($ruta); $carpeta = $zipfile->carpeta; $archivo = $zipfile->archivo; for ($i = 0; $i < count($carpeta); $i++) { $zipfile->add_dir(str_replace("reporte/u743/", "reporte/", $carpeta[$i])); //$zipfile->add_dir( $carpeta[$i] ); } for ($i = 0; $i < count($archivo); $i++) { $zipfile->add_file($archivo[$i], str_replace("reporte/u743/", "reporte/", $archivo[$i])); //$zipfile->add_file($archivo[$i],$archivo[$i] ); } header("Content-type: application/octet-stream"); header("Content-disposition: attachment; filename=bandeja.zip"); echo $zipfile->file(); exit; } else { $filename = Helpers::convert_to_file_excel('Bandeja_' . date("Ymd_His")); header('Content-Type: application/octet-stream; charset=utf-8;'); header('Content-Disposition: attachment; filename=' . $filename); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header("Content-Transfer-Encoding: binary"); header('Pragma: public'); $n = 1; foreach ($gestion['datos'] as $data) { //Encabezado if ($n == 1) { foreach ($data as $key => $val) { echo $key . "\t"; } echo "\r\n"; } //Datos foreach ($data as $val) { $val = str_replace(array("\r\n", "\n", "\n\n", "\t", "\r"), array("", "", "", "", ""), $val); echo $val . "\t"; } echo "\r\n"; $n++; } } // }
public function export() { ini_set("max_execution_time", 600); $this->load->model('module/nfe'); if (isset($this->request->get['date_start'])) { $data['date_start'] = $this->request->get['date_start']; } else { $data['date_start'] = date('Y-m-d'); } if (isset($this->request->get['date_end'])) { $data['date_end'] = $this->request->get['date_end']; } else { $data['date_end'] = date('Y-m-d'); } if (isset($this->request->get['cfop'])) { $data['cfop'] = $this->request->get['cfop']; } else { $data['cfop'] = ''; } $results = $this->model_module_nfe->getNfes($data); $results_inutil = $this->model_module_nfe->getNfesInutil(isset($this->request->get['date_start']) ? $this->request->get['date_start'] : date('Y-m-d'), isset($this->request->get['date_end']) ? $this->request->get['date_end'] : date('Y-m-d')); $name_export = 'export' . date('dmYHis') . '.zip'; require_once DIR_SYSTEM . 'library/zip.php'; $ziper = new Zipfile(); $exist = false; if (count($results_inutil) > 0) { foreach ($results_inutil as $result_inutil) { //INCLUI ARQUIVOS DE INUTILIZACAO $ziper->addFile(file_get_contents(DIR_NFE_FILES . 'inutilizadas/' . $result_inutil['id'] . '-procInut.xml'), date('d-m-Y', strtotime($result_inutil['dhRecbto'])) . '_' . $result_inutil['id'] . '-procInut.xml'); } } $directory = DIR_NFE_FILES . 'canceladas'; $filenames = array(); function browse($dir) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_file($dir . '/' . $file)) { $filenames[] = $dir . '/' . $file; } else { if ($file != "." && $file != ".." && is_dir($dir . '/' . $file)) { browse($dir . '/' . $file); } } } closedir($handle); } return $filenames; } $filenames = browse($directory); foreach ($filenames as $filename) { $file = $filename; $arquivo = substr($file, -3); if ($arquivo == "xml") { $ziper->addFile($filename, $filename); } } if (count($results) > 0) { foreach ($results as $result) { //INCLUI ARQUIVO DANFE .pdf if (is_file(DIR_NFE_FILES . 'enviadas/aprovadas/' . $result['chave_nota'] . '-nfe.xml')) { //INCLUI ARQUIVO NFE .pdf if (is_file(DIR_NFE_FILES . 'pdf/' . $result['chave_nota'] . '-nfe.pdf')) { $ziper->addFile(file_get_contents(DIR_NFE_FILES . 'pdf/' . $result['chave_nota'] . '-nfe.pdf'), date('d-m-Y', strtotime($result['data_emissao'])) . '_' . $result['chave_nota'] . '-nfe.pdf'); } //INCLUI ARQUIVO NFE .xml $ziper->addFile(file_get_contents(DIR_NFE_FILES . 'enviadas/aprovadas/' . $result['chave_nota'] . '-nfe.xml'), date('d-m-Y', strtotime($result['data_emissao'])) . '_' . $result['chave_nota'] . '-nfe.xml'); //INCLUI REC CANCELAMENTO SE A NOTA ESTIVER CANCELADA if (is_file(DIR_NFE_FILES . 'temporarias/' . $result['chave_nota'] . '-retCanc.xml')) { $ziper->addFile(file_get_contents(DIR_NFE_FILES . 'temporarias/' . $result['chave_nota'] . '-retCanc.xml'), date('d-m-Y', strtotime($result['data_emissao'])) . '_' . $result['chave_nota'] . '-procCanc.xml'); } $exist = true; } } if ($exist) { $ziper->output(DIR_NFE_FILES . 'export/' . $name_export); exit("<script>window.location.href = 'index.php?route=sale/nfe&token=" . $this->request->get['token'] . "&download_file=../nfe/files/producao/export/" . $name_export . "';</script>"); } exit("<script>window.location.href = 'index.php?route=sale/nfe&token=" . $this->request->get['token'] . "&error=Nenhuma nfe(.pdf) válida foi encontrada!';</script>"); } else { exit('Não há registros a serem exportados!<br /><a onclick="history.go(-1)" style="text-decoration:underline;cursor:pointer">voltar</a>'); } }