Categories > OpenTBS with DOCX >

Conditional displaying in WORD

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: mpol
Date: 2013-09-08
Time: 22:28

Conditional displaying in WORD

Hello
I have the the following Table
Positions: (Klasse, Art, Summe) The Value of Klasse could be Ertrag or Aufwand
My Quers is: $TBS->MergeBlock('ueb',$cnx_id,"SELECT * FROM view_rollup Where Periode='B-2014'");

This is working in Word: [ueb.Art;block=tbs:row] but I want to put a condtios to show this value if the ueb.Klasse=='Aufwand'. Can I use a condition in Word?

The following is not working:  [ueb.Art;block=tbs:row; if [var.Klasse]=‘Aufwand‘]

Could you please advise where to check?
thanks
mpol_ch
By: mpol
Date: 2013-09-09
Time: 19:16

Re: Conditional displaying in WORD

Hello
I triying to use the the following code in docx template. It works but I have repeating rows with auf.Art.  In DB I have 3 records for aus.Art and 7 receords for ert.Art. How can I set a condition to say no repeating on the auf.Art side? I tried many option but no obe helped.

[auf.Art;block=tbs:p]    [auf.Summe]    [ert.Art;block=tbs:p]    [ert.Summe]

mpol_ch
By: Skrol29
Date: 2013-09-09
Time: 23:24

Re: Conditional displaying in WORD

Hi MPol,

> This is working in Word: [ueb.Art;block=tbs:row] but I want to put a condtios to show this value if the ueb.Klasse=='Aufwand'.

Do you want to hide the value or hide the row ?
To hide only the value : [ueb.Art;block=tbs:row; if [var.Klasse]='Aufwand';then '']

> How can I set a condition to say no repeating on the auf.Art side?

Is that embedded blocks ?
Does a GROUP BY in the SQL query can make it ?
By: mpol
Date: 2013-09-10
Time: 09:26

Re: Conditional displaying in WORD

Hello
I am receiving the following error for this code:
[auf.Art;block=tbs:row; if[var.Klasse]=’Aufwand’;then’’]

Error START
TinyButStrong Error in block's definition [auf.Art...]: at least one tag corresponding to tbs:row is not found. Check opening tags, closing tags and embedding levels.

TinyButStrong Error in field [var.Klasse...]: the key 'Klasse' does not exist or is not set in VarRef. (VarRef seems refers to $GLOBALS) This message can be cancelled using parameter 'noerr'.

TinyButStrong Error Show() Method: The output is cancelled by the OpenTBS plugin because at least one error has occured.
Error END:

My PHP file contens:
<?php

include_once('tbs_us/tbs_class.php');
include_once('tbs_plugin_opentbs/tbs_plugin_opentbs.php');

//Connexion to the database
// Use the example below.
$cnx_id = mysql_connect('localhost','root','');
mysql_select_db('buxxx232',$cnx_id);

$sql_ok = ( isset($cnx_id) && is_resource($cnx_id) ) ? 1 : 0;
if ($sql_ok==0) $cnx_id = 'clear'; // makes the block to be cleared instead of merged with an SQL query.

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

$TBS->LoadTemplate('vorlagen/budgetvorlage.docx');

$TBS->MergeBlock('auf',$cnx_id,"SELECT * FROM view_rollup Where Periode='B-2014' AND Klasse='Aufwand' Order by Summe ");
$TBS->MergeBlock('ert',$cnx_id,"SELECT * FROM view_rollup Where Periode='B-2014' AND Klasse='Ertrag' Order by Summe");

$TBS->MergeBlock('blk1',$cnx_id,"SELECT * FROM view_positionen Where Periode='B-2014'");

$TBS->Show();

I am trying to show the Results of "auf" and "ert" in a 4 column table. The auf has 3 rows and the ert has 7 rows. In this case I receive all 7 rows of ert but in same table for coloumns of auf I get repeated values...

thanks
By: Skrol29
Date: 2013-09-14
Time: 22:42

Re: Conditional displaying in WORD

> TinyButStrong Error in block's definition [auf.Art...]: at least one tag corresponding to tbs:row is not found.

This error message can happen when you're forgotten a closing character (]).
Or when your TBS field is split by Ms Office or LibreOffice by an inner formating XML entity.
In order to avid this second possibility, just cut the TBS field (including the brackets) and past it back using the "Paste only the text" button in the Past options.
It may also help t apply the "Do not check spelling and grammar" (button "Language" in the "Review" ribbon).

> TinyButStrong Error in field [var.Klasse...]: the key 'Klasse' does not exist or is not set in VarRef. (VarRef seems refers to $GLOBALS) This message can be cancelled using parameter 'noerr'.

[var] fields are only for PHP global variables  or items saved in property $TBS->VarRef.
You probably mean [auf.Klasse] in this context instead of [var.Klasse].

> In this case I receive all 7 rows of ert but in same table for columns of auf I get repeated values...

Why don't you avoid doubles using a GROUP BY clause in your SQL query ?