/** * 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 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>'); } }