Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 14th, 2012  |  syntax: None  |  size: 0.59 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class InventoryItem extends Zend_Db_Table_Row_Abstract
  2. {      
  3.         public function quantity($location = null)
  4.         {
  5.                 $invMgr = new Inventory();
  6.                 $select = $this->select()->setIntegrityCheck(false);
  7.  
  8.                 $select->from('Inventory', 'SUM(qty_onhand) AS qty')
  9.                            ->where('item_id = ?', $this->item_id, Zend_Db::INT_TYPE)
  10.                            ->group('item_id');
  11.  
  12.                 if ($location) {
  13.                         $select->where('location_id = ?', $location, Zend_Db::INT_TYPE);
  14.                 }
  15.  
  16.                 $res = $select->query(Zend_Db::FETCH_OBJ)->fetch();
  17.                 return (int)$res->qty;
  18.         }
  19. }
  20.  
  21. // transfers.php
  22. $thing = new InventoryItem();
  23. echo $thing->quantity(1);