Categories > OpenTBS with DOCX >

MergeBlock MySQL header/footer in docx

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: mpol_ch
Date: 2016-12-29
Time: 13:25

MergeBlock MySQL header/footer in docx

Hallo
I am having a docx template which is working perfectly.
Now I am trying to insert the result in area of header  and  footer with the following code, which is not working.
[a;block=begin] [h.firma]

When I put this code in outside in header area then it works perfectly.
Could you pelase give a hint how this code should be look like in header?

thanks
mpol_ch
By: Skrol29
Date: 2016-12-30
Time: 00:21

Re: MergeBlock MySQL header/footer in docx

In DOCX, header and footer are saved in a separated sub-file.
This you have to use command OPENTBS_SELECT_HEADER or OPENTBS_SELECT_FOOTER before to manually merge in it.
  See http://www.tinybutstrong.com/opentbs.php?doc#opentbs_select_header

But automatic fields ([onload] and [onshow]) are always processed in header and footer.
By: mpol_ch
Date: 2016-12-30
Time: 18:38

Re: MergeBlock MySQL header/footer in docx

Hi
thanks for the answer.
But du you have an example how I can use this one? I appreciate much if you would give me some more information.

I used the following code but with no success:
[a;block=begin] [h.firma]   //For docx template in area header

In my PHP File:

<?php
include_once('tbs_us/tbs_class.php');
include_once('tbs_plugin_opentbs/tbs_plugin_opentbs.php');
$conn = mysqli_connect("localhost","****","","*****");


if (version_compare(PHP_VERSION,'5.1.0')>=0) {
    if (ini_get('date.timezone')=='') {
        date_default_timezone_set('UTC');
    }
}


if(mysqli_connect_error()){
exit('Connect failed: '. mysqli_connect_error());
}

$TBS = new clsTinyButStrong;
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
$TBS->PlugIn(OPENTBS_SELECT_HEADER, [$Type[, $Offset])
$TBS->PlugIn(OPENTBS_SELECT_FOOTER, [$Type[, $Offset])

$Id=$_GET['Id']; //Rechnungs ID
$KId=$_GET['KId'];
$FId=$_GET['FId'];
//$fallId=$_GET['Fall'];

$template = 'vorlagen/vorschuss.docx';
$TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8);

$TBS->MergeBlock('h',$conn,"SELECT *, f.f_name as firma FROM firma AS f INNER JOIN mitarbeiter AS m ON f.f_id = m.Firma Where m.MId=44"); //Reserviert für Header und Footer

$output_file_name = str_replace('.', '_'.date('d_m_Y').'.', $template);
$TBS->Show(OPENTBS_DOWNLOAD, $output_file_name);
exit();
//$TBS->Show();
?>

thanks
mpol_ch