function getCurrentQty() { //return $this->getStock(SettingsTable::get("default_warehouse_id"))->getCurrentQty(); $stock = StockTable::fetch(SettingsTable::fetch("default_warehouse_id"), $this->getId()); return $stock->getCurrentQty(); }
<?php if ($form->getObject()->getId()) { foreach (WarehouseTable::fetchAll() as $warehouse) { $stock = StockTable::fetch($warehouse->getId(), $form->getObject()->getId()); //$this->redirect("stock/view?id=".$stock->getId()); echo link_to("Go to " . $warehouse . " stock", "stock/view?id=" . $stock->getId()) . "<br>"; } } ?>
<?php foreach ($products as $index => $product) { ?> <h1><?php echo link_to($product->getName(), "product/edit?id=" . $product->getId()); ?> </h1> <table border=1> <tr> <td>Warehouse</td> <td>Qty</td> <td>View</td> </tr> <?php foreach (WarehouseTable::fetchAll() as $warehouse) { $stock = StockTable::fetch($warehouse->getId(), $product->getId()); ?> <tr> <td><?php echo $warehouse->getName(); ?> </td> <td><?php echo $stock->getCurrentQty(); ?> </td> <td><?php echo link_to("View", "stock/view?id=" . $stock->getId()); ?> </td> </tr>
public function getStock() { if ($this->stock == null or $force) { $this->stock = StockTable::fetch(SettingsTable::fetch("default_warehouse_id"), $this->getProductId()); } return $this->stock; //return StockTable::fetch($this->getWarehouseId(), $this->getProductId()); }