function invoice_edit_item in Invoice 7
Same name and namespace in other branches
- 6 invoice_ajax.inc \invoice_edit_item()
Edit an invoice item
1 string reference to 'invoice_edit_item'
- invoice_menu in ./
invoice.module - Implements hook_menu()
File
- ./
invoice_ajax.inc, line 278 - Invoice module
Code
function invoice_edit_item() {
$fv =& $_GET;
$data = array();
// Check if the item to delete exists
$invoice_item = db_query("SELECT * FROM {invoice_items} WHERE iid = :iid", array(
':iid' => $fv['iid'],
))
->fetchObject();
if ($invoice_item) {
// Check user admin access for this invoice
if (!_invoice_user_has_admin_access_to_invoice($invoice_item->invoice_id)) {
$data['error'] = t('You are not the owner of this item id!');
drupal_json_output($data);
exit;
}
$data['description'] = $invoice_item->description;
$data['vat'] = $invoice_item->vat;
$data['quantity'] = $invoice_item->quantity;
$data['exunitcost'] = $invoice_item->unitcost;
$data['incunitcost'] = $invoice_item->unitcost * _invoice_vat_percent_to_decimal(variable_get('invoice_vat', 0));
$data['actionvalue'] = t('Save item');
}
else {
$data['error'] = t('This item id does not exist!');
}
drupal_json_output($data);
exit;
}