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(); }
// 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 $OOo->MergeBlock('eleves',$tab_eleves_OOo); $OOo->SaveXmlToDoc(); //traitement du fichier extrait //Génération du nom du fichier $now = gmdate('d_M_Y_H:i:s'); $nom_fichier_modele = explode('.',$nom_fichier_modele_ooo); $nom_fic = $nom_fichier_modele[0]."_".$now.".".$nom_fichier_modele[1]; /* header('Expires: ' . $now); if (my_ereg('MSIE', $_SERVER['HTTP_USER_AGENT'])) { header('Content-Disposition: inline; filename="' . $nom_fic . '"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="' . $nom_fic . '"');
$blk_content[] = array('i_num' => 10, 's_ref' => '3300501000057', 's_ean' => '', 's_design' => 'Caffeine Candy Sampler v5.0', 'f_eur' => 19.99, 'f_teur' => 0); // compute invoice sum $f_total = 0; while (list($id, $fd) = each($blk_content)) { $blk_content[$id]['f_teur'] = $blk_content[$id]['i_num'] * $blk_content[$id]['f_eur']; $f_total += $blk_content[$id]['f_teur']; } $f_gtotal = $f_total * (1 + $f_vat_rate / 100); $f_vat = $f_gtotal - $f_total; // ============================================================================ // M A I N // ============================================================================ $OOo->NewDocFromTpl('example_invoice.sxw'); // ===== xml content ========================================================== $OOo->LoadXmlFromDoc('content.xml'); $OOo->MergeBlock('blk_ship', 'array', $blk_ship); $OOo->MergeBlock('blk_content', 'array', $blk_content); $OOo->SaveXmlToDoc(); // ===== xml meta ============================================================= $OOo->LoadXmlFromDoc('meta.xml'); $OOo->SaveXmlToDoc(); // ============================================================================ // D I S P L A Y // ============================================================================ switch ($header) { // method 1 : send to the browser via header location (problem with IE) case 'location': header('Location:' . $OOo->GetPathnameDoc()); break; // method 2 : send to the browser via header content-type // method 2 : send to the browser via header content-type
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(); $OOo->RemoveDoc();
<?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 '../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())); $OOo->FlushDoc(); $OOo->RemoveDoc();
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 ????? } } }
$Mes=$io_funsob->uf_convertir_numeromes($Mes); $Ano=date("Y"); $Fecha=date("d/m/Y"); // setting the object $OOo->SetZipBinary('zip'); $OOo->SetUnzipBinary('unzip'); $OOo->SetProcessDir('tmp/'); // create a new openoffice document from the template with an unique id $lb_valido=$OOo->NewDocFromTpl($ls_ruta); //merge data with openoffice file named 'content.xml' $OOo->LoadXmlFromDoc('content.xml',$ls_ruta); if(is_array($la_condiciones)) $OOo->MergeBlock('tblCondicionPago',$la_condiciones); if(is_array($la_retenciones)) $OOo->MergeBlock('tblRetenciones',$la_retenciones); if(is_array($la_garantias)) $OOo->MergeBlock('tblGarantias',$la_garantias); $OOo->SaveXmlToDoc($ls_ruta); // display header('Content-type: '.$OOo->GetMimetypeDoc()); header('Content-Length: '.filesize($OOo->GetPathnameDoc())); $OOo->FlushDoc(); $OOo->RemoveDoc(); ?>
include_once '../tbs_class.php'; include_once '../tbsooo_class.php'; // datas $result[0] = array('country' => 'United States', 'city' => 'Washington', 'winner' => 'Bob', 'score' => 100); $result[1] = array('country' => 'United States', 'city' => 'Washington', 'winner' => 'Julia', 'score' => 99); $result[2] = array('country' => 'United States', 'city' => 'Washington', 'winner' => 'Mark', 'score' => 78); $result[3] = array('country' => 'United States', 'city' => 'New York', 'winner' => 'Stanley', 'score' => 110); $result[4] = array('country' => 'United States', 'city' => 'New York', 'winner' => 'Robert', 'score' => 109); $result[5] = array('country' => 'France', 'city' => 'Paris', 'winner' => 'Pierre', 'score' => 250); $result[6] = array('country' => 'France', 'city' => 'Paris', 'winner' => 'Jean', 'score' => 210); $result[7] = array('country' => 'France', 'city' => 'Paris', 'winner' => 'Gaël', 'score' => 120); $result[8] = array('country' => 'France', 'city' => 'Toulouse', 'winner' => 'Emmanuelle', 'score' => 260); $result[9] = array('country' => 'France', 'city' => 'Toulouse', 'winner' => 'Louis', 'score' => 240); $result[10] = array('country' => 'France', 'city' => 'Toulouse', 'winner' => 'Jaques', 'score' => 200); // 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_prmheader.sxw'); // merge data with openoffice file named 'content.xml' $OOo->LoadXmlFromDoc('content.xml'); $OOo->MergeBlock('blk_res', $result); $OOo->SaveXmlToDoc(); // display header('Content-type: ' . $OOo->GetMimetypeDoc()); header('Content-Length: ' . filesize($OOo->GetPathnameDoc())); $OOo->FlushDoc(); $OOo->RemoveDoc();
include_once ("./lib/chemin.inc.php"); // instantiate a 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->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->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 $OOo->MergeBlock('blk1',$donnee_tab_protagonistes) ; // Fin de traitement des tableaux $OOo->SaveXmlToDoc(); //traitement du fichier extrait //Génération du nom du fichier $now = gmdate('d_M_Y_H:i:s'); $nom_fichier_modele = explode('.',$nom_fichier_modele_ooo); //$nom_fic = $nom_fichier_modele[0]."_N°_".$num_incident."_généré_le_".$now.".".$nom_fichier_modele[1]; $nom_fic = $nom_fichier_modele[0]."_N_".$num_incident."_genere_le_".$now.".".$nom_fichier_modele[1]; header('Expires: ' . $now); // lem9 & loic1: IE need specific headers if (my_ereg('MSIE', $_SERVER['HTTP_USER_AGENT'])) {
<?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();
<?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();
include_once '../tbs_class.php'; include_once '../tbsooo_class.php'; // datas $recset[] = array('title' => 'I will love you', 'rank' => 'A'); $recset[] = array('title' => 'Tender thender', 'rank' => 'B'); $recset[] = array('title' => 'I got you babe', 'rank' => 'C'); $recset[] = array('title' => 'Only with you', 'rank' => 'D'); $recset[] = array('title' => 'Love me tender', 'rank' => 'E'); $recset[] = array('title' => 'Wait for me', 'rank' => 'F'); $recset[] = array('title' => 'Happy pop', 'rank' => 'G'); $recset[] = array('title' => 'Kiss me like that', 'rank' => 'H'); $recset[] = array('title' => 'Love me so', 'rank' => 'I'); $recset[] = array('title' => 'Us, you and I', 'rank' => 'J'); // 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_prmserial.sxw'); // merge data with openoffice file named 'content.xml' $OOo->LoadXmlFromDoc('content.xml'); $OOo->MergeBlock('bx', $recset); $OOo->MergeBlock('bz', $recset); $OOo->SaveXmlToDoc(); // display header('Content-type: ' . $OOo->GetMimetypeDoc()); header('Content-Length: ' . filesize($OOo->GetPathnameDoc())); $OOo->FlushDoc(); $OOo->RemoveDoc();
}//end del if de documento "CONTRATO" //--------------------------Datos Generales--------------------------------------------// $Dia=date("d"); //$dia=$io_funsob->convertir(700850390); $Mes=date("m"); $Mes=$io_funsob->uf_convertir_numeromes($Mes); $Ano=date("Y"); $Fecha=date("d/m/Y"); // setting the object $OOo->SetZipBinary('zip'); $OOo->SetUnzipBinary('unzip'); $OOo->SetProcessDir('tmp/'); // create a new openoffice document from the template with an unique id $lb_valido=$OOo->NewDocFromTpl($ls_ruta); //merge data with openoffice file named 'content.xml' $OOo->LoadXmlFromDoc('content.xml',$ls_ruta); $OOo->MergeBlock('tabla',$la_condiciones); $OOo->SaveXmlToDoc($ls_ruta); // display header('Content-type: '.$OOo->GetMimetypeDoc()); header('Content-Length: '.filesize($OOo->GetPathnameDoc())); $OOo->FlushDoc(); $OOo->RemoveDoc(); ?>
$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, ' ', $row_curr); } $i++; } $row_list .= $row_curr; } $OOo->MergeBlock('blk1', 'text', $row_list); $OOo->SaveXmlToDoc(); // display header('Content-type: ' . $OOo->GetMimetypeDoc()); header('Content-Length: ' . filesize($OOo->GetPathnameDoc())); $OOo->FlushDoc(); $OOo->RemoveDoc();
} if ($CurrRec['res_score'] < 100) { $CurrRec['level'] = 'bad'; } if ($CurrRec['res_score'] >= 100) { $CurrRec['level'] = 'middle'; } if ($CurrRec['res_score'] >= 200) { $CurrRec['level'] = 'good'; } if ($CurrRec['res_score'] >= 300) { $CurrRec['level'] = 'excellent'; } } // 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_event.sxw'); // merge data with openoffice file named 'content.xml' $OOo->LoadXmlFromDoc('content.xml'); $OOo->MergeBlock('b1', $data_array); $OOo->SaveXmlToDoc(); // display header('Content-type: ' . $OOo->GetMimetypeDoc()); header('Content-Length: ' . filesize($OOo->GetPathnameDoc())); $OOo->FlushDoc(); $OOo->RemoveDoc();