Categories > OpenTBS with DOCX >

Headergrp

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Rodrigo
Date: 2015-08-27
Time: 17:39

Headergrp

Hi,

First of all let me say thanks for such a wonderful library. I've been using it for quite some time with great success.

For this project I'm working, I have a table in a .docx template like this (one cell per row):

+----------------------------------------------------------------------+
| Client : [blk.client;block=tbs:row;headergrp=client]                |
+----------------------------------------------------------------------+
| Item : [blk.item;block=tbs:row+tbs:row;headergrp=item]       |
+----------------------------------------------------------------------+
| Subitem : [blk.subitem;block=tbs:row;headergrp=subitem]     |
+----------------------------------------------------------------------+

What I want is to report all Subitems for each change in Client and Item. What I did was basically an adaptation of the example from http://www.tinybutstrong.com/examples.php?e=grouping&m=result

However the output gives me only one Subitem for each change in Client and Item. If I use an html template like the example it renders ok (lots of subitems per changes)

If I drop the first two rows from the template leaving only the Subitem block it shows everything.

My PHP Source:
// DB connection
$cnx_id = mysql_connect('localhost','****','****');

// load the TinyButStrong libraries
include_once('tbs_class.php');
include_once('tbs_plugin_opentbs.php');

$TBS = new clsTinyButStrong;
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);

// Retrieve the template to open
$template = 'template.docx';
$TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8);

$TBS->PlugIn(OPENTBS_SELECT_MAIN);
$TBS->MergeBlock('blk', $cnx_id,"select client,item,subitem from stocktable");
$TBS->Show(OPENTBS_FILE, "report.docx");

Ideally what I want is:

- For each change in Client start a new page with a block of text at the beginning with the Client data
- Next I want a table with repeating headers (in case there are lots of subitems spawning several rows on multiple pages)
- For each Item change I want a starting row beneath the header row with the Item data
- Then all of the remaining rows are Subitem data

An output like this:

-- newpage

Client AAA

+----------------------------------------------------------------------+
| Item 1                                                                                  |
+----------------------------------------------------------------------+
| Subitem 1                                                                            |
+----------------------------------------------------------------------+
| Subitem 2                                                                            |
+----------------------------------------------------------------------+
| ...                                                                                        |
+----------------------------------------------------------------------+
| Item 2                                                                                  |
+----------------------------------------------------------------------+
| Subitem 1                                                                            |
+----------------------------------------------------------------------+
| Subitem 2                                                                            |
+----------------------------------------------------------------------+
| ...                                                                                        |
+----------------------------------------------------------------------+

-- newpage

Client BBB

+----------------------------------------------------------------------+
| Item 1                                                                                  |
+----------------------------------------------------------------------+
| Subitem 1                                                                            |
+----------------------------------------------------------------------+
| Subitem 2                                                                            |
+----------------------------------------------------------------------+
| ...                                                                                        |
+----------------------------------------------------------------------+
| Item 2                                                                                  |
+----------------------------------------------------------------------+
| Subitem 1                                                                            |
+----------------------------------------------------------------------+
| Subitem 2                                                                            |
+----------------------------------------------------------------------+
| ...                                                                                        |
+----------------------------------------------------------------------+

Any ideas?
By: Rodrigo
Date: 2015-08-27
Time: 17:58

Re: Headergrp

Nevermind! Found the solution...using parentgrp instead of headergrp