You are here

function _pminvoice_insert_items in Drupal PM (Project Management) 7

Save invoice items to database.

2 calls to _pminvoice_insert_items()
pminvoice_insert in pminvoice/pminvoice.module
Implements hook_insert().
pminvoice_update in pminvoice/pminvoice.module
Implements hook_update().

File

pminvoice/pminvoice.module, line 645
1: Hooks (help, perm, init, menu, theme, node_info) 2: Access functions 3: Load organization and project details 4: Invoice create / edit form 5: Invoice node manipulation functions 6: Admin settings 7: Views hook 8: Project Managementinvoiceitem…

Code

function _pminvoice_insert_items($node) {
  foreach ($node->items as $j => $item) {
    $node->items[$j]->src_nid = isset($node->items[$j]->src_nid) ? $node->items[$j]->src_nid : $node->src_nid;
    $node->items[$j]->src_vid = isset($node->items[$j]->src_vid) ? $node->items[$j]->src_vid : $node->src_vid;
    db_insert('pminvoice_items')
      ->fields(array(
      'invoice_nid' => $node->nid,
      'invoice_vid' => $node->vid,
      'amount' => $item->amount,
      'description' => $item->description,
      'tax1app' => $item->tax1app,
      'tax1percent' => $item->tax1percent,
      'tax1' => $item->tax1,
      'tax2app' => $item->tax2app,
      'tax2percent' => $item->tax2percent,
      'tax2' => $item->tax2,
      'total' => $item->total,
      'weight' => $item->weight,
    ))
      ->execute();
  }
  db_delete('pminvoice_items')
    ->condition('invoice_vid', $node->vid)
    ->condition('total', 0)
    ->condition('description', '')
    ->execute();
}