Categories > OpenTBS with ODS >

OTS Problem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Verlhac Gaëtan
Date: 2014-04-24
Time: 10:33

OTS Problem

Hi everyone,

First, the problem: I want to display a double var in a percentage format. But my OTS file displays it like a string (i.e.: '0.7 instead of 70,00%).
To be noticed:
1 - I use TBS and OpenTBS on Symfony2 thanks to mbence (https://github.com/mbence/OpenTBSBundle).
2 - As you can see the Bundle uses TBS 3.8.2 and OpenTBS 1.8.2


Now the code:
In my PHP :
$entiteQuotePart = $dossierEntite->getQuotepart() / 100;

$tbs->MergeField(
    'client',
    array(
        ...,
        'quotepart' => $entiteQuotePart,
        ...
    )
);
$dossierEntite->getQuotepart() returns an integer and if I do log the type $entiteQuotePart it says double.

In the OTS file:
[client.quotepart;ope=tbs:percent]
The OTS file is in French language by default.
The cell where this code resides is in "Pourcentage > -12,95 % > Par défaut - Français (France)" with the format "0,00%"


What I've done:
1 - Read the demo included in the download - seems like I have the same code as the example.
2 - Update TBS and OpenTBS to latest version
3 - Set $entiteQuotePart global and use onshow

None of this was successful.


Maybe I missed something, but I'm locked and I need your help.

Thanks,
Gaëtan.
By: Skrol29
Date: 2014-04-24
Time: 14:47

Re: Problem with tbs:percent

Bonjour Verlhac,

I did know OpenTBSBundle, it is good to know it.

I didn't succeed in reproducing your problem.
Since it looks like a simple wrapper for Symfony, I can not explain what the Percentage formating is not working.

What you can do is to check the XML content near your TBS field using command OPENTBS_DEBUG_XML_CURRENT.
May be the parameter "ope=tbs:percent" is split internally.
By: Verlhac Gaëtan
Date: 2014-04-28
Time: 11:03

Re: Problem with tbs:percent

Hi Skrol29,

When I'm using OPENTBS_DEBUG_XML_CURRENT I get the following:
<table:table-cell table:style-name="ce27" office:value-type="string">
  <text:p>
   0.3
  </text:p>
</table:table-cell>

Looks like it's ignoring the
ope=tbs:percent
and writing the double value as is... (Also ignoring the cell percentage format I used.)

I tried to used each tbs:xxx formatted like they are in your demo:
[onshow.x_num;ope=tbs:num]
[onshow.x_num;ope=tbs:curr]
[onshow.x_pc;ope=tbs:percent]
[onshow.x_bt;ope=tbs:bool]
And none is working x_x

EDIT: Okay now I understand, I'm using OTS (Model) and not ODS. If I change my model from OTS to ODS it's working.
My problem is that I cannot use ODS...

From the DEBUG I can see:
------------------------------
INFORMATION
------------------------------
* Debug command: OPENTBS_DEBUG_XML_CURRENT
* OpenTBS version: 1.9.0
* TinyButStrong version: 3.9.0
* PHP version: 5.4.15YES
* Opened document: C:\Program Files\UwAmp\www\ToDoList\src\todolist\TodolistBundle\Controller/../Resources/files/ModelefactureFR.ots
* Activated features for document type: odf/ots
* Deleted files in the archive: none
* Added files in the archive: none
* Modified files in the archive:
  - styles.xml
  - content.xml

Is there a way OTS acting different than ODS?
By: Skrol29
Date: 2014-04-28
Time: 23:55

Re: Problem with tbs:percent

Hi,

After the template is loaded, try:
$TBS->PlugIn(OPENTBS_FORCE_DOCTYPE, 'ods');

If it works, I will make OpenTBS to recognize the OTS extension to be equivalent to ODS.
By: Verlhac Gaëtan
Date: 2014-04-29
Time: 09:35

Re: Problem with tbs:percent

Hi Skrol29,

It's working with the line you gave me.

I'm grateful to you.


Petite parenthèse, j'ai vu que tu parlais français. Pourrais-tu renommer le sujet en quelque chose qui contiendrai "OTS" pour qu'au cas où ce sujet aide quelqu'un ;)
Et merci pour TBS et OpenTBS que j'apprécie.

Cordialement,
viviengaetan.
By: Skrol29
Date: 2014-04-29
Time: 17:13

Re: Problem with tbs:percent

> Pourrais-tu renommer le sujet en quelque chose qui contiendrai "OTS"

Ok, c'est fait :)
Merci à toi.