I'm working on a new website, output to a .docx using openTBS. I have an table of financial data by and I'm trying to get it to display in word.
I have written a test program
$debug = 0;
$query = 'SELECT * from financial WHERE company_id = \'' . $_SESSION['company_id'] . "' and projection='0' ";
$result = mysqli_query($link, $query) or die("FAILED to get financial from database");
while ($financial = mysqli_fetch_assoc($result)) {
$fsa[$financial['year_ending_yyyy_mm']]['gross_sales'] = number_format($financial['gross_sales'], $decimals, $decimal_point, $thousands_sep);
$income = $financial['gross_sales'] - $financial['cogs'] - $financial['overhead_expenses'] + $financial['interest_income'] - $financial['contributions']
- $financial['interest_expense'] - $financial['amortization_expense'] - $financial['depreciation_expense'];
$fsa[$financial['year_ending_yyyy_mm']]['recast_ebitda'] = calculate_recast_ebitda($financial['year_ending_yyyy_mm'], $link, $financial);
$fsa[$financial['year_ending_yyyy_mm']]['income'] = number_format($income, $decimals, $query, $thousands_sep);}
if ($debug == 1) {
print_r($fsa);
} else {
include_once('tbs_class.php');
include_once('tbs_plugin_opentbs.php');
$TBS = new clsTinyButStrong;
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
//$TBS->SetOption('noerr', true);
$TBS->LoadTemplate(NON_WEB_DIR . 'templates/' . 'fsa.docx');
$TBS->MergeBlock('fsa', $fsa);
$TBS->Show(OPENTBS_DOWNLOAD, $file_name);
} |
When I run with debug I get the following so I know that my data is good:
Array ( [2011_2] => Array ( [gross_sales] => 1,234.00 [recast_ebitda] => -134567 [income] => -124,975S00 ) [2012_2] => Array ( [gross_sales] => 1,234.00 [recast_ebitda] => -134567 [income] => -124,975S00 ) ) |
When I run with debug = 0 I get:
TinyButStrong Error in field [fsa.cogs...]: item 'cogs' is not an existing key in the array. This message can be cancelled using parameter 'noerr'.
TinyButStrong Error in field [fsa.key...]: item 'key' is not an existing key in the array. This message can be cancelled using parameter 'noerr'.
TinyButStrong Error in field [fsa.cogs...]: item 'cogs' is not an existing key in the array. This message can be cancelled using parameter 'noerr'.
TinyButStrong Error in field [fsa.key...]: item 'key' is not an existing key in the array. 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.
I have modeled my template on the examples. It looks like this:
Year Ending Sales
[fsa.$ ;block=w:tr] [fsa.gross_sales] [fsa.key] [fsa.cogs]
|
I feel like I am missing something obvious because I've done this before. I've tried a billion variations but nothing works.. I would be happy to either go directly from the query to the MergeBlock if that is more efficient. I only build the array to have something to merge. Any help or suggestions would be appreciated.
Thanks,
David