function render_csv() { /* Define template */ // start the csv template $template_csv = new template_engine(); // load template $template_csv->prepare_load_template("templates/csv/report_incomestatement.csv"); /* Fill in template fields */ // mode $template_csv->prepare_add_field("mode", $this->mode); // dates $template_csv->prepare_add_field("date_start", time_format_humandate($this->date_start)); $template_csv->prepare_add_field("date_end", time_format_humandate($this->date_end)); $template_csv->prepare_add_field("date_created", time_format_humandate()); // totals $template_csv->prepare_add_field("amount_total_income", $this->data_totals["income"]); $template_csv->prepare_add_field("amount_total_expense", $this->data_totals["expense"]); $template_csv->prepare_add_field("amount_total_final", $this->data_totals["final"]); // income data $structure_main = NULL; foreach ($this->data_income as $itemdata) { $structure = array(); $structure["name_chart"] = $itemdata["code_chart"] . " -- " . $itemdata["description"]; $structure["amount"] = format_money($itemdata["amount"]); $structure_main[] = $structure; } $template_csv->prepare_add_array("table_income", $structure_main); // income data $structure_main = NULL; foreach ($this->data_expense as $itemdata) { $structure = array(); $structure["name_chart"] = $itemdata["code_chart"] . " -- " . $itemdata["description"]; $structure["amount"] = format_money($itemdata["amount"]); $structure_main[] = $structure; } $template_csv->prepare_add_array("table_expense", $structure_main); /* Output Template */ // fill template $template_csv->prepare_filltemplate(); // display csv foreach ($template_csv->processed as $line) { print $line; } }
function render_csv() { /* Define template */ // start the csv template $template_csv = new template_engine(); // load template $template_csv->prepare_load_template("templates/csv/report_balancesheet.csv"); /* Fill in template fields */ // mode $template_csv->prepare_add_field("mode", $this->mode); // dates $template_csv->prepare_add_field("date_end", time_format_humandate($this->date_end)); $template_csv->prepare_add_field("date_created", time_format_humandate()); // totals $template_csv->prepare_add_field("amount_total_current_earnings", $this->data_totals["current_earnings"]); $template_csv->prepare_add_field("amount_total_assets", $this->data_totals["assets"]); $template_csv->prepare_add_field("amount_total_liabilities", $this->data_totals["liabilities"]); $template_csv->prepare_add_field("amount_total_equity", $this->data_totals["equity"]); $template_csv->prepare_add_field("amount_total_liabilities_and_equity", $this->data_totals["liabilities_and_equity"]); // asset data $structure_main = NULL; foreach ($this->data_assets as $itemdata) { $structure = array(); $structure["name_chart"] = $itemdata["code_chart"] . " -- " . $itemdata["description"]; $structure["amount"] = format_money($itemdata["amount"]); $structure_main[] = $structure; } $template_csv->prepare_add_array("table_assets", $structure_main); // liabilities data $structure_main = NULL; foreach ($this->data_liabilities as $itemdata) { $structure = array(); $structure["name_chart"] = $itemdata["code_chart"] . " -- " . $itemdata["description"]; $structure["amount"] = format_money($itemdata["amount"]); $structure_main[] = $structure; } $template_csv->prepare_add_array("table_liabilities", $structure_main); // equity data $structure_main = NULL; foreach ($this->data_equity as $itemdata) { $structure = array(); $structure["name_chart"] = $itemdata["code_chart"] . " -- " . $itemdata["description"]; $structure["amount"] = format_money($itemdata["amount"]); $structure_main[] = $structure; } $template_csv->prepare_add_array("table_equity", $structure_main); /* Output Template */ // fill template $template_csv->prepare_filltemplate(); // display csv foreach ($template_csv->processed as $line) { print $line; } }