Exemplo n.º 1
0
function export2odt($template_full_path, $template_mime_type, $data, $display, $save_path=""){
  
  $data_vars = $data["data_vars"];
  $data_blocks = $data["data_blocks"];
 
  // instantiate a TBS OOo class
  $OOo = new clsTinyButStrongOOo; 
  
  // setting the object
  if ($OOo->SetZipBinary('zip', true) == false) {
    // erreur zip non présent
  }
  if ($OOo->SetUnzipBinary('unzip', true) == false) {
    // erreur unzip non présent
  }
  if ($OOo->SetProcessDir('/tmp/') == false) {
    // erreur /tmp inaccessible
  }

  // create a new openoffice document from the template with an unique id
 
 $OOo->NewDocFromTpl($template_full_path);
 
 // merge data with OOo file content.xml
  $OOo->LoadXmlFromDoc('content.xml');
  
  
  // load Data
  foreach($data_vars as $key => $value){
    $GLOBALS[$key] = $value;
  }

  
  // Merge Data
  foreach ($data_blocks as $key => $value) {
    $OOo->MergeBlock($key, $value);
  }
  $OOo->SaveXmlToDoc();
  
  if ($display){
   
      if ($template_mime_type == "")
        $template_mime_type = $OOo->GetMimetypeDoc();
      if ($template_mime_type == "")
        $template_mime_type = "sxw";
     
      header('Content-type: '.$template_mime_type);
      header('Content-Length: '.filesize($OOo->GetPathnameDoc())); 
      header('Content-Disposition: inline; filename=cv.'.$template_mime_type);
      $OOo->FlushDoc();
      $OOo->RemoveDoc(); 
  }
  else {
    if ($save_path != "") {
      rename($OOo->GetPathnameDoc(), $save_path);
      // affichage des document sauvés ?????
    }
  }
}
Exemplo n.º 2
0
 private function reporteTBSOO($informe)
 {
     define('BASE', sfConfig::get('sf_app_module_dir') . '/informes/lib/');
     require_once BASE . 'tbs_class_php5.php';
     require_once BASE . 'tbsooo_class.php';
     $OOo = new clsTinyButStrongOOo();
     $OOo->noErr = true;
     $OOo->SetZipBinary('zip');
     $OOo->SetUnzipBinary('unzip');
     $OOo->SetProcessDir(sfConfig::get('sf_informe_dir'));
     $OOo->SetDataCharset('UTF8');
     $OOo->NewDocFromTpl(sfConfig::get('sf_informe_dir') . DIRECTORY_SEPARATOR . $informe->getAdjunto()->getRuta());
     $OOo->LoadXmlFromDoc('content.xml');
     $aVariable = $this->leerTemplate($OOo->Source);
     $aDato = array();
     //busco en las variables encontradas en el template y reemplaza contenido
     $aDato = $this->llenarVariables($aVariable);
     //agregando datos del registro informe
     $aDato['informe'] = $informe->toArray();
     // variables adicionales dinamicas de los formulario
     if ($informe->getVariables()) {
         $aDato['variable'] = array();
         $variables = explode(";", $informe->getVariables());
         foreach ($variables as $variable) {
             $pos = stripos($variable, ":");
             if ($pos) {
                 $variable = substr($variable, 0, $pos);
             }
             $aDato['variable'] = array_merge($aDato['variable'], array($variable => $this->getRequestParameter($variable)));
         }
     }
     // lleno finalmente de diferente forma si es un array (ciclo) o no (variable comun)
     if (is_array($aDato)) {
         foreach ($aDato as $idx => $dato) {
             if ($this->isNotAssocArray($dato)) {
                 $OOo->MergeBlock($idx, "array", $dato);
             } else {
                 $OOo->MergeField($idx, $dato);
             }
         }
     }
     $OOo->SaveXmlToDoc();
     // OJO hay headers locos para que funcione en internet explorer
     header('Content-type: ' . $OOo->GetMimetypeDoc());
     //header("Content-Type: application/force-download"); //para que funcione en konqueror
     header("Cache-Control: public, must-revalidate");
     header("Pragma: hack");
     header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
     header('Content-Disposition: attachment; filename="informe' . $informe->getNombre() . '.odt"');
     header("Content-Transfer-Encoding: binary");
     $OOo->FlushDoc();
     $OOo->RemoveDoc();
 }
<?php

include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
$x = 'Hello World';
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('tbsooo_us_examples_hello.sxw');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->SaveXmlToDoc();
// display
header('Content-type: ' . $OOo->GetMimetypeDoc());
header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc();
$OOo->RemoveDoc();
Exemplo n.º 4
0
<?php

include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
$x = 1.23;
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('format_float.ods');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->SaveXmlToDoc();
// display
header('Content-type: ' . $OOo->GetMimetypeDoc());
header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc();
$OOo->RemoveDoc();
Exemplo n.º 5
0
<?php

include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
$x = 'Hello World';
$d = '2005-10-04';
$n = 0.1234;
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
$OOo->SetDataCharset('UTF8');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('charset_utf8.sxw');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->SaveXmlToDoc();
// display
header('Content-type: ' . $OOo->GetMimetypeDoc());
header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc();
$OOo->RemoveDoc();
Exemplo n.º 6
0
<?php

// ============================================================================
// I N C L U D E
// ============================================================================
include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// ============================================================================
// R E Q U E S T
// ============================================================================
$header = isset($_GET['header']) ? $_GET['header'] : 'content';
// ============================================================================
// I N I T
// ============================================================================
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// set the binary ZIP
//$OOo->SetZipBinary('/usr/bin/zip', true);
if ($OOo->SetZipBinary('zip', true) == false) {
    die;
}
// set the binary UNZIP
//$OOo->SetUnzipBinary('/usr/bin/unzip', true);
if ($OOo->SetUnzipBinary('unzip', true) == false) {
    die;
}
// set the process directory
if ($OOo->SetProcessDir('tmp/') == false) {
    die;
}
// ============================================================================
Exemplo n.º 7
0
if($fb_gab_perso=="1"){ 
  // Gestion du multisite
  if ($_SESSION['rne']!='') {
	$rne=$_SESSION['rne']."/";
  } else {
	$rne='';
  }
  $nom_dossier_modele_a_utiliser="../../mod_ooo/mes_modeles/".$rne;
}
else{
  $nom_dossier_modele_a_utiliser="../../mod_ooo/modeles_gepi/";
}
// TODO vérifier les chemins comme /mod_ooo/lib/chemin.inc.php

// Création d'une classe  TBS OOo class
$OOo = new clsTinyButStrongOOo;
$OOo->SetDataCharset('UTF-8');

// setting the object
$OOo->SetProcessDir($nom_dossier_temporaire ); //dossier où se fait le traitement (décompression / traitement / compression)
// create a new openoffice document from the template with an unique id
//$OOo->createFrom($nom_dossier_modele_a_utiliser.$nom_fichier_modele_ooo); // le chemin du fichier est indiqué à partir de l'emplacement de ce fichier
// create a new openoffice document from the template with an unique id 
$OOo->NewDocFromTpl($nom_dossier_modele_a_utiliser.$nom_fichier_modele_ooo); // le chemin du fichier est indiqué à partir de l'emplacement de ce fichier
// merge data with openoffice file named 'content.xml'
//$OOo->loadXml($nom_fichier_xml_a_traiter); //Le fichier qui contient les variables et doit être parsé (il sera extrait)
$OOo->LoadXmlFromDoc($nom_fichier_xml_a_traiter); //Le fichier qui contient les variables et doit être parsé (il sera extrait)


// Traitement des tableaux
// On insère ici les lignes concernant la gestion des tableaux
<?php

include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
$country = array('France', 'England', 'Spain', 'Italy', 'Germany');
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('tbsooo_us_examples_blocks.sxw');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->MergeBlock('blk1', $country);
$OOo->MergeBlock('blk2', $country);
$OOo->MergeBlock('blk3', $country);
$OOo->MergeBlock('blk4', $country);
$OOo->MergeBlock('blk5', $country);
$OOo->SaveXmlToDoc();
// display
header('Content-type: ' . $OOo->GetMimetypeDoc());
header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc(true);
$OOo->DeleteDoc();
include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
$TeamList[0] = array('team' => 'Eagle', 'total' => '458');
$TeamList[0]['matches'][] = array('town' => 'London', 'score' => '253', 'date' => '1999-11-30');
$TeamList[0]['matches'][] = array('town' => 'Paris', 'score' => '145', 'date' => '2002-07-24');
$TeamList[1] = array('team' => 'Goonies', 'total' => '281');
$TeamList[1]['matches'][] = array('town' => 'New-York', 'score' => '365', 'date' => '2001-12-25');
$TeamList[1]['matches'][] = array('town' => 'Madrid', 'score' => '521', 'date' => '2004-01-14');
$TeamList[2] = array('team' => 'MIB', 'total' => '615');
$TeamList[2]['matches'][] = array('town' => 'Dallas', 'score' => '362', 'date' => '2001-01-02');
$TeamList[2]['matches'][] = array('town' => 'Lyon', 'score' => '321', 'date' => '2002-11-17');
$TeamList[2]['matches'][] = array('town' => 'Washington', 'score' => '245', 'date' => '2003-08-24');
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('tbsooo_us_examples_subblock.sxw');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->MergeBlock('mb', 'array', 'TeamList');
$OOo->MergeBlock('sb', 'array', 'TeamList[%p1%][matches]');
$OOo->SaveXmlToDoc();
// display
header('Content-type: ' . $OOo->GetMimetypeDoc());
header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc();
Exemplo n.º 10
0
//les chemins contenant les données
$fb_gab_perso = getSettingValue("fb_gab_perso");
if ($fb_gab_perso == "1") {
    // Gestion du multisite
    if ($_SESSION['rne'] != '') {
        $rne = $_SESSION['rne'] . "/";
    } else {
        $rne = '';
    }
    $nom_dossier_modele_a_utiliser = "../../mod_ooo/mes_modeles/" . $rne;
} else {
    $nom_dossier_modele_a_utiliser = "../../mod_ooo/modeles_gepi/";
}
// TODO vérifier les chemins comme /mod_ooo/lib/chemin.inc.php
// Création d'une classe  TBS OOo class
$OOo = new clsTinyButStrongOOo();
$OOo->SetDataCharset('UTF-8');
// setting the object
$OOo->SetProcessDir($nom_dossier_temporaire);
//dossier où se fait le traitement (décompression / traitement / compression)
// create a new openDocument document from the template with an unique id
//$OOo->createFrom($nom_dossier_modele_a_utiliser.$nom_fichier_modele_ooo); // le chemin du fichier est indiqué à partir de l'emplacement de ce fichier
// create a new openDocument document from the template with an unique id
$OOo->NewDocFromTpl($nom_dossier_modele_a_utiliser . $nom_fichier_modele_ooo);
// le chemin du fichier est indiqué à partir de l'emplacement de ce fichier
// merge data with openDocument file named 'content.xml'
//$OOo->loadXml($nom_fichier_xml_a_traiter); //Le fichier qui contient les variables et doit être parsé (il sera extrait)
$OOo->LoadXmlFromDoc($nom_fichier_xml_a_traiter);
//Le fichier qui contient les variables et doit être parsé (il sera extrait)
// Traitement des tableaux
// On insère ici les lignes concernant la gestion des tableaux
include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
$array_type1 = array();
$array_type1 = array('France' => 33, 'England' => 44, 'Spain' => 34, 'Italy' => 39, 'Deutchland' => 49);
$array_type2[] = array('res_name' => 'Marie', 'res_score' => 300, 'res_date' => '2003-01-10');
$array_type2[] = array('res_name' => 'Eric', 'res_score' => 215, 'res_date' => '2003-01-10');
$array_type2[] = array('res_name' => 'Mark', 'res_score' => 180, 'res_date' => '2003-01-10');
$array_type2[] = array('res_name' => 'Paul', 'res_score' => 175, 'res_date' => '2003-01-10');
$array_type2[] = array('res_name' => 'Mat', 'res_score' => 120, 'res_date' => '2003-01-10');
$array_type2[] = array('res_name' => 'Sonia', 'res_score' => 115, 'res_date' => '2003-01-10');
$all_array['type1'] = $array_type1;
$all_array['type2'] = $array_type2;
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('tbsooo_us_examples_dataarray.sxw');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->MergeBlock('blk1', $array_type1);
$OOo->MergeBlock('blk2', $array_type2);
$OOo->MergeBlock('blk3', 'array', 'all_array[type2]');
$OOo->SaveXmlToDoc();
// display
header('Content-type: ' . $OOo->GetMimetypeDoc());
header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
session_start();
?>
<?php

		/* --------------------------------------------------------------------------------------------------------------------
			Clase:	        			sigesp_sob_d_documentos_contrato
		 	Descripción:				Clase que se encarga de generar contratos a partir de plantillas en OpenOffice		
		 	Fecha de Creación:          12/05/2006																			
			Fecha ultima modificación:	20/06/2006																			
		    Autora:          			Ing. Laura Cabré																			
	 	  --------------------------------------------------------------------------------------------------------------------*/
//----------------------Clases y objetos necesarios para generar los documentos OOo--//
	include_once('class_folder/tbs_class.php');
	include_once('class_folder/tbsooo_class.php');
	// instantiate a TBS OOo class
	$OOo = new clsTinyButStrongOOo;

//-------------------Otras clases---------------------------------------------------//
include_once('class_folder/sigesp_sob_c_funciones_sob.php');
$io_funsob=new sigesp_sob_c_funciones_sob();
require_once("../shared/class_folder/class_funciones.php");
$io_function=new class_funciones();

//-------------------Obteniendo arreglo y variables de datos basicos----------------------------//
$ls_ruta=$_GET["ruta"];

//-----------Obteniedo la data a ser enviada al documento OpenOffice------------------------//

	//--------------------------Datos del Contrato------------------------------------------//
	$la_contrato=$io_funsob->uf_decodificar($_GET["contrato"]);
	$la_unidadmulta=$io_funsob->uf_decodificar($_GET["unidadmulta"]);
<?php

include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('tbsooo_us_examples_datanum.sxc');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->MergeBlock('blk1', 'num', 7);
$OOo->MergeBlock('blk2', 'num', array('min' => -17, 'max' => 0, 'step' => -2));
$OOo->SaveXmlToDoc();
// display
header('Content-type: ' . $OOo->GetMimetypeDoc());
header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc();
$OOo->RemoveDoc();
Exemplo n.º 14
0
<?php

include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
$blk_query = array();
$blk_query[] = array('fn' => 'Joe', 'sn' => 'Smith', 'mark' => '56');
$blk_query[] = array('fn' => 'Fred', 'sn' => 'Jones', 'mark' => '78');
$blk_query[] = array('fn' => 'Sue', 'sn' => 'Kendall', 'mark' => '27');
$blk_query[] = array('fn' => 'Helen', 'sn' => 'Nguyen', 'mark' => '84');
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('one_row_per_page_break.sxw');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->MergeBlock('blk1', $blk_query);
$OOo->SaveXmlToDoc();
// display
header('Content-type: ' . $OOo->GetMimetypeDoc());
header('Content-Length: ' . filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc(true);
$OOo->DeleteDoc();
session_start();
?>
<?php

		/* --------------------------------------------------------------------------------------------------------------------
			Clase:	        			sigesp_sob_d_documentos_puntodecuenta
		 	Descripción:				Script que se encarga de generar Puntos de Cuenta a partir de plantillas en OpenOffice		
		 	Fecha de Creación:          29/06/2006																			
			Fecha ultima modificación:	29/06/2006																			
		    Autora:          			Ing. Laura Cabré																			
	 	  --------------------------------------------------------------------------------------------------------------------*/
//----------------------Clases y objetos necesarios para generar los documentos OOo--//
	include_once('class_folder/tbs_class.php');
	include_once('class_folder/tbsooo_class.php');
	// instantiate a TBS OOo class
	$OOo = new clsTinyButStrongOOo;

//-------------------Otras clases---------------------------------------------------//
include_once('class_folder/sigesp_sob_c_funciones_sob.php');
$io_funsob=new sigesp_sob_c_funciones_sob();
require_once("../shared/class_folder/class_funciones.php");
$io_function=new class_funciones();

//-------------------Obteniendo arreglo y variables de datos basicos----------------------------//
$ls_ruta=$_GET["ruta"];

//-----------Obteniedo la data a ser enviada al documento OpenOffice------------------------//
		$la_puntodecuenta=$io_funsob->uf_decodificar($_GET["puntodecuenta"]);
		$ls_codigopresupuestariomonto=$_GET["codigopresupuestariomonto"];
		$ls_cuentamonto=$_GET["cuentamonto"];
		$ls_codigopresupuestarioiva=$_GET["codigopresupuestarioiva"];
Exemplo n.º 16
0
<?php

include_once '../tbs_class.php';
include_once '../tbsooo_class.php';
// datas
$nbr = isset($_GET['nbr']) ? $_GET['nbr'] : 30;
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo();
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('tmp/');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('tbsooo_us_examples_loops.sxw');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
//We get the HTML source that designs the block
$row_tpl = $OOo->GetBlockSource('blk1');
//Variables initialization
$row_list = '';
$i = 1;
//Starting the loop
while ($i <= $nbr) {
    $row_curr = $row_tpl;
    for ($cell = 1; $cell <= 7; $cell++) {
        if ($i <= $nbr) {
            $row_curr = str_replace('x' . $cell, $i, $row_curr);
        } else {
            $row_curr = str_replace('x' . $cell, '&nbsp;', $row_curr);
        }
        $i++;