function _invoice_get_invoice_items in Invoice 7
Same name and namespace in other branches
- 6 invoice_form.inc \_invoice_get_invoice_items()
Form helper function to get all invoice items
Parameters
integer $invoice_id:
Return value
array
1 call to _invoice_get_invoice_items()
- invoice_form in ./
invoice_form.inc - Implements hook_form()
File
- ./
invoice_form.inc, line 816 - Invoice module
Code
function _invoice_get_invoice_items($invoice_id = 0) {
$i = 0;
$invoice_id = intval($invoice_id);
$invoice_items_table_rows = array();
$sql_addition = $invoice_id > 0 ? ' ' . intval($invoice_id) : '';
$result = db_query("SELECT * FROM {invoice_items} WHERE uid = :uid AND invoice_id = :invoice_id\n ORDER BY weight, created ASC", array(
':uid' => $GLOBALS['user']->uid,
':invoice_id' => $invoice_id,
))
->fetchAll();
$form['page_names'] = array();
foreach ($result as $row) {
$i++;
$token = drupal_get_token($row->iid);
$invoice_items_table_rows[] = array(
'data' => array(
nl2br(check_plain($row->description)),
$row->vat . '%',
$row->quantity,
_invoice_round_and_format_money($row->unitcost, 3),
_invoice_round_and_format_money($row->unitcost * _invoice_vat_percent_to_decimal($row->vat), 2),
_invoice_round_and_format_money($row->quantity * $row->unitcost, 2),
_invoice_round_and_format_money($row->quantity * $row->unitcost * _invoice_vat_percent_to_decimal($row->vat), 2),
array(
'data' => _invoice_get_icon('edit', NULL, array(
'class' => 'action-button edit-action mouse-pointer',
'title' => t('Edit'),
)) . _invoice_get_icon('delete', NULL, array(
'class' => 'action-button delete-action mouse-pointer',
'title' => t('Delete'),
)),
'class' => array(
'actions',
),
),
),
'class' => array(
'item-' . $row->iid,
'iitoken-' . $token,
'invoice-item',
'draggable',
),
);
}
return array(
'rows' => $invoice_items_table_rows,
'count' => $i,
);
}