public function updateFit($EFTFit, $desc, $quantity, $setupId, $fitId) { $fitModel = $this->model->getModel('fit'); $fitRow = $fitModel->getFit($fitId); $fit = new fit($fitRow['typeName'], $fitRow['name'], $fitRow['shiptypeId'], $fitRow['groupName'], $this->user->getId(), $desc, $fitRow['id'], $fitRow['publishDate'], $fitRow['updateDate']); $fit->setQuantity($quantity); $fit->parseEFT($EFTFit, $this->model); $fit->setNeedsSave(true); $this->getSetup($setupId)->replaceFit($fitId, $fit); $this->save(); }
/** * Retrieves fits from the database or session depending on if the user is loggedin * @return array */ public function getSetups() { $setups = array(); if ($this->loggedin) { // Get setups /** @var setupModel $setupModel */ $setupModel = $this->model->getModel('setup'); $setupRows = $setupModel->getSetups(); foreach ($setupRows as $setupRow) { $setups[$setupRow['id']] = new setup((int) $setupRow['id'], $setupRow['name'], $setupRow['description'], $setupRow['userId'], $setupRow['username'], $setupRow['publishDate'], $setupRow['updateDate']); } // Get fits and assign them to the correct setup /** @var fitModel $fitModel */ $fitModel = $this->model->getModel('fit'); $fitRows = $fitModel->getFits(); foreach ($fitRows as $fitRow) { $fit = new fit($fitRow['typeName'], $fitRow['name'], $fitRow['shiptypeId'], $fitRow['groupName'], $this->getId(), $fitRow['description'], $fitRow['id'], $fitRow['publishDate'], $fitRow['updateDate']); $fit->setQuantity($fitRow['qty']); $fit->parseEFT($fitRow['EFTData'], $this->model); if (isset($setups[$fitRow['setupId']])) { $setups[$fitRow['setupId']]->addFit($fit); } } } return $setups; }