You are here

function _invoice_get_variable in Invoice 6

Same name and namespace in other branches
  1. 7 invoice_helpers.inc \_invoice_get_variable()

Helper function to get template variables

8 calls to _invoice_get_variable()
invoice_delete_item in ./invoice_ajax.inc
Delete an invoice item
invoice_form in ./invoice_form.inc
Implementatin of node_form()
invoice_invoices in ./invoice.module
Overview of all invoices
invoice_load in ./invoice.module
Implementation of hook_load()
invoice_save_item in ./invoice_ajax.inc
Add an invoice item

... See full list

File

./invoice_helpers.inc, line 457
Invoice module

Code

function _invoice_get_variable($template, $name, $default = NULL) {

  // if $template is empty, check if a general/default value is available
  if (empty($template)) {
    return variable_get('invoice_' . $name, '');
  }
  static $a_templates = NULL;

  // Get all template settings from the database only one time
  if (!is_array($a_templates)) {
    $a_templates_names = _invoice_get_templates();
    $a_templates = array();
    $result = db_query("SELECT * FROM {invoice_templates} WHERE name IN ('" . implode("','", $a_templates_names) . "')");
    while ($row = db_fetch_array($result)) {
      $a_templates[$row['name']] = $row;
    }
  }

  // Get template info that is stored in the database
  $a_template = $a_templates[$template];
  if (!empty($a_template[$name]) || is_numeric($a_template[$name])) {
    return $a_template[$name];
  }
  else {
    if (!is_null($default)) {
      return $default;
    }
    else {

      // if $default is not null, check if a general/default value is available
      return variable_get('invoice_' . $name, '');
    }
  }
}