public function getCurrentStats()
 {
     $aData = array();
     $aData["partCount"] = PartManager::getInstance()->getPartCount();
     $aData["categoryCount"] = PartCategoryManager::getInstance()->getCategoryCount();
     $aData["totalPrice"] = PartManager::getInstance()->getTotalPrice();
     $aData["averagePrice"] = PartManager::getInstance()->getAveragePrice();
     $aData["partsWithPrice"] = PartManager::getInstance()->getPartCount(true);
     $aData["partsWithoutPrice"] = $aData["partCount"] - $aData["partsWithPrice"];
     $result = PartUnitManager::getInstance()->getUnitCounts();
     $aUnits = array();
     foreach ($result as $row) {
         $aUnits[] = array("name" => PartUnit::loadById($row["puid"])->getName(), "stockLevel" => $row["stockLevel"]);
     }
     $aData["units"] = $aUnits;
     return $aData;
 }
 public function createSnapshot()
 {
     $snapshot = new StatisticSnapshot();
     $snapshot->setParts(PartManager::getInstance()->getPartCount());
     $snapshot->setCategories(PartCategoryManager::getInstance()->getCategoryCount());
     $result = PartUnitManager::getInstance()->getUnitCounts();
     foreach ($result as $row) {
         $snapshotUnit = new StatisticSnapshotUnit();
         $snapshotUnit->setPartUnit(PartUnit::loadById($row["puid"]));
         $snapshotUnit->setStatisticSnapshot($snapshot);
         if ($row["stockLevel"] !== null) {
             $snapshotUnit->setStockLevel($row["stockLevel"]);
         } else {
             $snapshotUnit->setStockLevel(0);
         }
         $snapshot->getUnits()->add($snapshotUnit);
     }
     PartKeepr::getEM()->persist($snapshot);
     PartKeepr::getEM()->flush();
 }
示例#3
0
 public function deletePart()
 {
     PartManager::getInstance()->deletePart($this->getParameter("part"));
 }
示例#4
0
 public function deletePart($id)
 {
     $part = PartManager::getInstance()->getPart($id);
     PartKeepr::getEM()->remove($part);
     PartKeepr::getEM()->flush();
 }