public function saveRow(Document\Row $row = null, Document $document, Parameters $parameters) { if ($row == null) { $row = new Document\Row(); } if (!$row->getDocument()) { $row->setDocument($document); } if (isset($parameters->description) && $parameters->description != null) { $row->setDescription($parameters->description); } if (isset($parameters->code)) { if ($parameters->code != null) { $row->setCode($parameters->code); } else { $row->setCode(null); } } if (isset($parameters->uomId)) { $uom = $this->getOneObjectByField(Uom::getClass(), 'id', $parameters->uomId); $row->setUom($uom ? $uom : null); } if (isset($parameters->articleId)) { $article = $this->getOneObjectByField(Article::getClass(), 'id', $parameters->articleId); $row->setArticle($article ? $article : null); } if (isset($parameters->warehouse)) { $warehouse = $this->getOneObjectByField(Warehouse::getClass(), 'id', $parameters->warehouse); $row->setWarehouse($warehouse ? $warehouse : null); } if (isset($parameters->vatId)) { $vat = $this->getOneObjectByField(Vat::getClass(), 'id', $parameters->vatId); $row->setVat($vat ? $vat : null); } if (isset($parameters->quantity)) { $row->setQuantity($parameters->quantity); } if (isset($parameters->price) && $parameters->price != null) { $row->setPrice($parameters->price); } if (isset($parameters->quantity) && isset($parameters->price)) { $row->setAmount($parameters->quantity * $parameters->price); } if (isset($parameters->name) && $parameters->name != null) { $row->setName($parameters->name); } if ($document->getRows() && !$document->getRows()->contains($row)) { $document->addRow($row); } $this->entityManager->persist($row); $this->entityManager->flush($row); return $row; }
public function getArticlesByCodeOrName(User $user, $value) { return $this->entityManager->getRepository(Article::getClass())->getArticlesByCodeOrName($user, $value); }