TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

ODS column nested array

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Marko Remus
Date: 2016-08-01
Time: 09:46

ODS column nested array

Hi,

I have to create a booking statistic. The report should contain the booked item and it's nested properties like price, count and description. Please find the data structure below:

Array
(
    [0] => Array
        (
            [description] => Array
                (
                    [0] => Under 35
                    [1] => Full Rate
                )

            [count] => Array
                (
                    [0] => 3
                    [1] => 1
                )

            [amount] => Array
                (
                    [0] => 975.00
                    [1] => 815.00
                )

            [price] => Array
                (
                    [0] => 325.00
                    [1] => 815.00
                )

            [id] => Array
                (
                    [0] => 301317289496975
                    [1] => 301317289496966
                )

            [participantType] => Array
                (
                    [0] => 101245331463914
                    [1] => 101171877794528
                )

        )

    [1] => Array
        (
            [description] =>
            [count] => 2
            [amount] => 74.00
            [price] => 37.00
            [id] => 301317289498143
            [participantType] =>
        )

    [2] => Array
        (
            [description] =>
            [count] => 1
            [amount] => 50.00
            [price] => 50.00
            [id] => 301317289601222
            [participantType] =>
        )
)

Currently my template looks like that:

Program Point Category             Participant Type               Quantity    Price per Person         Total
[data.name;block=tbs:row;]    [pp.description;block=tbs:row;]    [pp.count]    [pp.price]             [pp.amount]
Currently for booked items with multiple descriptions the report just contains the value array instead of multiple rows each containing the corresponding description value. How can I create those rows with its value?

Thanks and Best regards
Marko

By: Marko Remus
Date: 2016-08-13
Time: 17:56

Re: ODS column nested array

Hi,

any chance of getting a hint into the right direction here?

Thanks
Marko
By: Skrol29
Date: 2016-08-17
Time: 23:47

Re: ODS column nested array

I think your value as array is too complicated for TBS merging. Especially if they are mixed with classic structure.

Why don't you simply create $data2 which is a copy of your data but with the structure expected by TBS, and then merge this $data2 ?
It would be a small piece of code.
By: Marko Remus
Date: 2016-08-18
Time: 01:49

Re: ODS column nested array

Hi Skrol29,

what would be the most useful datastracture in my scenario for TBS?
If possible I'd like to avoid multiple rows with the same value in column A even if the other columns contain multiple rows - do you know what I mean?

Many thanks in advance.
Best
Marko
By: Skrol29
Date: 2016-08-20
Time: 00:18

Re: ODS column nested array

The standard data structure is ans array like a recordset, that each record having the same items :
array(
  0 => array('colmun1' => val01, 'column2' => val02, ...),
  1 => array('colmun1' => val11, 'column2' => val12, ...),
  2 => array('colmun1' => val21, 'column2' => val22, ...),
  ...
);

Building this structure is easy in PHP, and you can yourself avoid multiple rows when builing it.
By: Marko Remus
Date: 2016-08-23
Time: 13:24

Re: ODS column nested array

Thanks for your feedback - it's now working as it should be :)
Thanks again for your support!