Categories > OpenTBS with DOCX >

Using Array Pointers in DOC/PPT/XLS Markup

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: John Porter
Date: 2014-06-12
Time: 00:20

Using Array Pointers in DOC/PPT/XLS Markup

I am trying to place specific values from a block into a section as a field.  I can get a continuous block no problem.  Specifically here though, the create individual slides, then check and delete ones that are not populated I need to create a single slide for each with about 10 block fields per.

The block syntax:

$TBS->MergeBlock('metrics', $data4 );

The document syntax which works but places them all on a single slide is

[metrics;block=begin][metrics.metric][metrics;block=end]

I would think you could do something like:

[metrics;block=begin][metrics.metric[0]][metrics;block=end]

Is there a way to do this?

By: Skrol29
Date: 2014-06-12
Time: 01:26

Re: Using Array Pointers in DOC/PPT/XLS Markup

Hi John,

It think I did dot understand your slide problem, but TBS accepts the following syntax for array sub items : [metrics.metric.0]
By: John Porter
Date: 2014-06-12
Time: 01:54

Re: Using Array Pointers in DOC/PPT/XLS Markup

Thank you for the quick response.  I am getting the following error when I use

[costs;block=begin] [costs.name.1][costs;block=end]

TinyButStrong Error in field [costs.name.1...]: item before '1' is neither an object nor an array. Its type is string. This message can be cancelled using parameter 'noerr'.

TinyButStrong Error in field [costs.name.1...]: item before '1' is neither an object nor an array. Its type is string. 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.

Any ideas?  It does work properly for the block when I leave it like:

[costs;block=begin] [costs.name][costs;block=end]

but it reads out all of them when I am looking for a specific one.  Thanks in advance.


By: Skrol29
Date: 2014-06-12
Time: 11:00

Re: Using Array Pointers in DOC/PPT/XLS Markup

Can you give more details about your data structure and what you'd like to achieve ?
By: John Porter
Date: 2014-06-12
Time: 14:25

Re: Using Array Pointers in DOC/PPT/XLS Markup

Here is what the data looks like:

VAR_EXPORT of our JSON Based Result

array ( 'totalRecs' => 10, 'metrics' => array ( 0 => array ( 'alt_metric_id' => '653', 'metric_id' => '1964', 'solution_id' => '273', 'metric' => 'Test Reduced Number of Calls into Call Center', 'sqq' => 'Number of Call to the Call Center', 'sqq_estimate' => '643760000', 'sqq_override' => '0', 'probable' => '0.1', 'conservative' => '0.05', 'aggressive' => '0.2', 'alt_impact' => '0', 'abbr' => '%', 'units' => 'Percent', 'unit_type_id' => '14', 'impact_per_unit' => '6', 'alt_impact_per_unit' => '0', 'sqq2' => 'Cost per Call?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1262', 'impact_type_id' => '1', 'sqq_y1' => '0', 'active' => '1', 'description' => 'By customers answering their own questions on the web, via mobile and IVR they are less likley to call the call center and reduce the overall service cost for that inquiry.', 'alt_metric_name' => 'Test Reduced Number of Calls into Call Center', 'alt_kpi_name' => 'Test Improve Customer Self-Service', 'impact' => 10, 'value_statement_content' => 'eliminates cost', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '643760000', 'sqq2_value' => 6, 'y1_total' => '386,256,000.00', 'y1_raw' => 386256000, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (10.00)% * Cost per Call? (6.00) * Number of Call to the Call Center (643,760,000.00) = 386,256,000.00 in year one.', 'value_statement' => 'Test Improve Customer Self-Service eliminates cost by Test Reduced Number of Calls into Call Center', ), 1 => array ( 'alt_metric_id' => '654', 'metric_id' => '1965', 'solution_id' => '273', 'metric' => 'Test Reduced Number of Call Center Agents', 'sqq' => 'Number of Call Center Agents', 'sqq_estimate' => '257504', 'sqq_override' => '0', 'probable' => '0.1', 'conservative' => '0.05', 'aggressive' => '0.2', 'alt_impact' => '0', 'abbr' => '%', 'units' => 'Percent', 'unit_type_id' => '14', 'impact_per_unit' => '30000', 'alt_impact_per_unit' => '0', 'sqq2' => 'Salary?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1262', 'impact_type_id' => '2', 'sqq_y1' => '0', 'active' => '1', 'description' => 'By customers answering their own questions on the web, via mobile and IVR they are less likley to call the call center and reduce the overall FTEs required to assist', 'alt_metric_name' => 'Test Reduced Number of Call Center Agents', 'alt_kpi_name' => 'Test Improve Customer Self-Service', 'impact' => 10, 'value_statement_content' => 'increases labor productivity', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '257504', 'sqq2_value' => 30000, 'y1_total' => '772,512,000.00', 'y1_raw' => 772512000, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (10.00)% * Salary? (30,000.00) * Number of Call Center Agents (257,504.00) = 772,512,000.00 in year one.', 'value_statement' => 'Test Improve Customer Self-Service increases labor productivity by Test Reduced Number of Call Center Agents', ), 2 => array ( 'alt_metric_id' => '655', 'metric_id' => '1966', 'solution_id' => '273', 'metric' => 'Test Improved Cross Sell / Upsell', 'sqq' => 'Number of Self-Service Customers', 'sqq_estimate' => '154502400', 'sqq_override' => '0', 'probable' => '0.15', 'conservative' => '0.1', 'aggressive' => '0.2', 'alt_impact' => '0', 'abbr' => '%', 'units' => 'Percent', 'unit_type_id' => '14', 'impact_per_unit' => '100', 'alt_impact_per_unit' => '0', 'sqq2' => 'Revenue per Offer?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1262', 'impact_type_id' => '4', 'sqq_y1' => '0', 'active' => '1', 'description' => 'By knowing the customer and its service history the selfservice channel can present the most relevant offfers to each customer.', 'alt_metric_name' => 'Test Improved Cross Sell / Upsell', 'alt_kpi_name' => 'Test Improve Customer Self-Service', 'impact' => 15, 'value_statement_content' => 'increases revenue', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '154502400', 'sqq2_value' => 100, 'y1_total' => '2,317,536,000.00', 'y1_raw' => 2317536000, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (15.00)% * Revenue per Offer? (100.00) * Number of Self-Service Customers (154,502,400.00) = 2,317,536,000.00 in year one.', 'value_statement' => 'Test Improve Customer Self-Service increases revenue by Test Improved Cross Sell / Upsell', ), 3 => array ( 'alt_metric_id' => '656', 'metric_id' => '1967', 'solution_id' => '273', 'metric' => 'Test Increased Customer Renewal Rate', 'sqq' => 'Number of Customers', 'sqq_estimate' => '257504000', 'sqq_override' => '0', 'probable' => '0.03', 'conservative' => '0.01', 'aggressive' => '0.05', 'alt_impact' => '0', 'abbr' => '%', 'units' => 'Percent', 'unit_type_id' => '14', 'impact_per_unit' => '500', 'alt_impact_per_unit' => '0', 'sqq2' => 'Revenue per Renewal?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1263', 'impact_type_id' => '4', 'sqq_y1' => '0', 'active' => '1', 'description' => 'Could also be Reduce number of churned customers', 'alt_metric_name' => 'Test Increased Customer Renewal Rate', 'alt_kpi_name' => 'Test Improve Customer Satisfaction.', 'impact' => 3, 'value_statement_content' => 'increases revenue', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '257504000', 'sqq2_value' => 500, 'y1_total' => '3,862,560,000.00', 'y1_raw' => 3862560000, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (3.00)% * Revenue per Renewal? (500.00) * Number of Customers (257,504,000.00) = 3,862,560,000.00 in year one.', 'value_statement' => 'Test Improve Customer Satisfaction. increases revenue by Test Increased Customer Renewal Rate', ), 4 => array ( 'alt_metric_id' => '657', 'metric_id' => '1968', 'solution_id' => '273', 'metric' => 'Test Reduced Cost to Serve', 'sqq' => 'Number of Customers', 'sqq_estimate' => '257504000', 'sqq_override' => '0', 'probable' => '0.02', 'conservative' => '0.01', 'aggressive' => '0.05', 'alt_impact' => '0', 'abbr' => '%', 'units' => 'Percent', 'unit_type_id' => '14', 'impact_per_unit' => '100', 'alt_impact_per_unit' => '0', 'sqq2' => 'Cost per Escalated Call?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1263', 'impact_type_id' => '2', 'sqq_y1' => '0', 'active' => '1', 'description' => 'Satisfied customers tend to be a lower cost to serve than unsatisfied customers', 'alt_metric_name' => 'Test Reduced Cost to Serve', 'alt_kpi_name' => 'Test Improve Customer Satisfaction.', 'impact' => 2, 'value_statement_content' => 'increases labor productivity', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '257504000', 'sqq2_value' => 100, 'y1_total' => '515,008,000.00', 'y1_raw' => 515008000, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (2.00)% * Cost per Escalated Call? (100.00) * Number of Customers (257,504,000.00) = 515,008,000.00 in year one.', 'value_statement' => 'Test Improve Customer Satisfaction. increases labor productivity by Test Reduced Cost to Serve', ), 5 => array ( 'alt_metric_id' => '658', 'metric_id' => '1969', 'solution_id' => '273', 'metric' => 'Test Improved Cross Sell / Upsell', 'sqq' => 'Number of Calls to the Call Center', 'sqq_estimate' => '643760000', 'sqq_override' => '0', 'probable' => '0.15', 'conservative' => '0.05', 'aggressive' => '0.25', 'alt_impact' => '0', 'abbr' => '%', 'units' => 'Percent', 'unit_type_id' => '14', 'impact_per_unit' => '100', 'alt_impact_per_unit' => '0', 'sqq2' => 'Revenue per Offer?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1264', 'impact_type_id' => '4', 'sqq_y1' => '0', 'active' => '1', 'description' => 'By knowing the customer and its service history the selfservice channel can present the most relevant offfers to each customer.', 'alt_metric_name' => 'Test Improved Cross Sell / Upsell', 'alt_kpi_name' => 'Test Improve Assisted Service', 'impact' => 15, 'value_statement_content' => 'increases revenue', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '643760000', 'sqq2_value' => 100, 'y1_total' => '9,656,400,000.00', 'y1_raw' => 9656400000, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (15.00)% * Revenue per Offer? (100.00) * Number of Calls to the Call Center (643,760,000.00) = 9,656,400,000.00 in year one.', 'value_statement' => 'Test Improve Assisted Service increases revenue by Test Improved Cross Sell / Upsell', ), 6 => array ( 'alt_metric_id' => '659', 'metric_id' => '1970', 'solution_id' => '273', 'metric' => 'Test Reduced Customer Litigation for Call Center Interactions', 'sqq' => 'Number of Customer Ligations per Year', 'sqq_estimate' => '1287.52', 'sqq_override' => '0', 'probable' => '0.4', 'conservative' => '0.2', 'aggressive' => '0.5', 'alt_impact' => '0', 'abbr' => '%', 'units' => 'Percent', 'unit_type_id' => '14', 'impact_per_unit' => '300000', 'alt_impact_per_unit' => '0', 'sqq2' => 'Cost per Litigation?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1264', 'impact_type_id' => '5', 'sqq_y1' => '0', 'active' => '1', 'description' => 'By tracking and recording calls into the call center you have documented proof of the conversation and content.', 'alt_metric_name' => 'Test Reduced Customer Litigation for Call Center Interactions', 'alt_kpi_name' => 'Test Improve Assisted Service', 'impact' => 40, 'value_statement_content' => 'mitigates risk', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '1287.52', 'sqq2_value' => 300000, 'y1_total' => '154,502,400.00', 'y1_raw' => 154502400, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (40.00)% * Cost per Litigation? (300,000.00) * Number of Customer Ligations per Year (1,287.52) = 154,502,400.00 in year one.', 'value_statement' => 'Test Improve Assisted Service mitigates risk by Test Reduced Customer Litigation for Call Center Interactions', ), 7 => array ( 'alt_metric_id' => '660', 'metric_id' => '1971', 'solution_id' => '273', 'metric' => 'Test Reduced Average Handle Time (AHT)', 'sqq' => 'Number of Calls to the Call Center', 'sqq_estimate' => '643760000', 'sqq_override' => '0', 'probable' => '5', 'conservative' => '2', 'aggressive' => '10', 'alt_impact' => '0', 'abbr' => 'Min', 'units' => 'Minutes', 'unit_type_id' => '9', 'impact_per_unit' => '0.25', 'alt_impact_per_unit' => '0', 'sqq2' => 'Wage per Minute?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1264', 'impact_type_id' => '2', 'sqq_y1' => '0', 'active' => '1', 'description' => 'Through automation, knowledge management and templated responses you can reduce the time to resolve customer inquiry', 'alt_metric_name' => 'Test Reduced Average Handle Time (AHT)', 'alt_kpi_name' => 'Test Improve Assisted Service', 'impact' => '5', 'value_statement_content' => 'increases labor productivity', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '643760000', 'sqq2_value' => 0.25, 'y1_total' => '804,700,000.00', 'y1_raw' => 804700000, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (5.00)Min * Wage per Minute? (0.25) * Number of Calls to the Call Center (643,760,000.00) = 804,700,000.00 in year one.', 'value_statement' => 'Test Improve Assisted Service increases labor productivity by Test Reduced Average Handle Time (AHT)', ), 8 => array ( 'alt_metric_id' => '661', 'metric_id' => '1972', 'solution_id' => '273', 'metric' => 'Test Reduced Number of Call Escalations', 'sqq' => 'Number of Calls to the Call Center', 'sqq_estimate' => '643760000', 'sqq_override' => '0', 'probable' => '0.05', 'conservative' => '0.02', 'aggressive' => '0.1', 'alt_impact' => '0', 'abbr' => '%', 'units' => 'Percent', 'unit_type_id' => '14', 'impact_per_unit' => '25', 'alt_impact_per_unit' => '0', 'sqq2' => 'Cost per Escalated Call?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1264', 'impact_type_id' => '2', 'sqq_y1' => '0', 'active' => '1', 'description' => 'Through automation, knowledge management and templated responses you can reduce the time to resolve customer inquiry with less requiring level two or higher escalation.', 'alt_metric_name' => 'Test Reduced Number of Call Escalations', 'alt_kpi_name' => 'Test Improve Assisted Service', 'impact' => 5, 'value_statement_content' => 'increases labor productivity', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '643760000', 'sqq2_value' => 25, 'y1_total' => '804,700,000.00', 'y1_raw' => 804700000, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (5.00)% * Cost per Escalated Call? (25.00) * Number of Calls to the Call Center (643,760,000.00) = 804,700,000.00 in year one.', 'value_statement' => 'Test Improve Assisted Service increases labor productivity by Test Reduced Number of Call Escalations', ), 9 => array ( 'alt_metric_id' => '662', 'metric_id' => '1973', 'solution_id' => '273', 'metric' => 'Test Reduced Agent Turnover', 'sqq' => 'Number of Agents', 'sqq_estimate' => '257504', 'sqq_override' => '0', 'probable' => '0.05', 'conservative' => '0.02', 'aggressive' => '0.1', 'alt_impact' => '0', 'abbr' => '%', 'units' => 'Percent', 'unit_type_id' => '14', 'impact_per_unit' => '2500', 'alt_impact_per_unit' => '0', 'sqq2' => 'Cost to Fill Vacancy?', 'source_type_id' => '0', 'y0' => '0', 'y1' => '1', 'y2' => '1', 'y3' => '1', 'sqq_y2' => '0', 'sqq_y3' => '0', 'accrual_type_id' => '1', 'kpi_id' => '1265', 'impact_type_id' => '2', 'sqq_y1' => '0', 'active' => '1', 'description' => 'Through automation, knowledge management and templated responses agents will be more satisfied with their work and will turnover less frequently', 'alt_metric_name' => 'Test Reduced Agent Turnover', 'alt_kpi_name' => 'Test Improve Employee Satisfaction', 'impact' => 5, 'value_statement_content' => 'increases labor productivity', 'areas' => 'No Business Areas Provided', 'industries' => 'All', 'business_models' => 'No Business Model Applicability Provided', 'competitors' => 'No Competitive Advantage Provided', 'success_factors' => 'No Critical Success Factors Provided', 'references' => 'No Customer References Provided', 'sqq_value' => '257504', 'sqq2_value' => 2500, 'y1_total' => '32,188,000.00', 'y1_raw' => 32188000, 'y2_total' => 0, 'y3_total' => 0, 'y2_raw' => 0, 'y3_raw' => 0, 'formula' => 'Our customers typically see an improvement of (5.00)% * Cost to Fill Vacancy? (2,500.00) * Number of Agents (257,504.00) = 32,188,000.00 in year one.', 'value_statement' => 'Test Improve Employee Satisfaction increases labor productivity by Test Reduced Agent Turnover', ), ), )

Basically in the above there are 10 "metrics" can we are creating a PPTX which has a single slide for each.  Based on the forums our approach is to create a slide for 100 of these and then deleting the slide if the values are null for that array pointer.  So in this case there would be 10 slides in other cases there may be more or less.  This is to basically create the same functionality that is easily done via page break in DOCX but is not supported in PPT.
By: Skrol29
Date: 2014-06-13
Time: 02:03

Re: Using Array Pointers in DOC/PPT/XLS Markup

Hi,

It is correct that OpenTBS cannot add slides in a PPTX. So you have to put all the possible slide for a merging and then delete unused slides at the end.

With yu data, you can merge each record to a slide with a loop like this:
$slide = 0;
foreach ($data['metrics'] as $i => $record) {
   $slide++;
   $TBS->PlugIn(OPENTBS_SELECT_SLIDE, $slide);
   $TBS->MergeField('metric', $record);
}

Then you have to delete extra slides.

Since you have only one record per slide, you don't need any block. Using MergeField() is enough to merge a set of fields.

It could be heavy to copy your slide  100 times in order to have 100 identical slides. So you try to copy the source of slide template of the first slide, and then reuse it for each slide.
I've never tested if this does not corrupt the Presentation.
This can be done like this:
$TBS->PlugIn(OPENTBS_SELECT_SLIDE, 1);
$template = $TBS->Source;

$slide = 0;
foreach ($data['metrics'] as $i => $record) {
   $slide++;
   $TBS->PlugIn(OPENTBS_SELECT_SLIDE, $slide);
   $TBS->Source = $template;
   $TBS->MergeField('metric', $record);
}