You are here

function _invoice_get_new_invoice_number in Invoice 6

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

Helper function to get invoice id

Return value

integer

2 calls to _invoice_get_new_invoice_number()
invoice_nodeapi in ./invoice.module
Implementation of hook_nodeapi()
invoice_validate in ./invoice.module
Implementation of node_validate()

File

./invoice_helpers.inc, line 297
Invoice module

Code

function _invoice_get_new_invoice_number($user_defined_invoice_number_check = FALSE) {
  if ($user_defined_invoice_number_check == TRUE) {
    $count = db_result(db_query("SELECT COUNT(*) FROM {invoice_invoices}"));
    if ($count == 0) {
      return 0;
    }
    else {
      return db_result(db_query_range("SELECT iid FROM {invoice_invoices} ORDER BY nid DESC", array(), 1));
    }
  }
  $new_invoice_number = db_result(db_query_range("SELECT iid FROM {invoice_invoices} ORDER BY nid DESC", array(), 1)) + 1;
  return $new_invoice_number;
}