public function saveWithParams(Article $article = null, User $user, array $data) { if (!$article) { $article = new Article(); $article->setUser($user); } if (isset($data['name'])) { $article->setName($data['name']); } if (isset($data['code'])) { $article->setCode($data['code']); } if (isset($data['salesPrice'])) { $article->setSalesPrice($data['salesPrice']); } if (isset($data['qty'])) { $article->setQuantity($data['qty']); } if (isset($data['description'])) { $article->setDescription($data['description']); } if (isset($data['uom'])) { if ($data['uom'] > 0) { $uom = $this->settingsService->getUomById($data['uom']); $article->setUom($uom); } } return $this->saveArticle($article); }
public function assembleInvoiceRowsArrayFromPost(array $data) { $invoiceRows = array(); foreach ($data['names'] as $key => $value) { $vat = $this->settingsService->getVatById($data['vatIds'][$key]); $uom = $this->settingsService->getUomById($data['uomIds'][$key]); $article = $this->articleService->getArticleById($data['articleIds'][$key]); $rowArray = array('rowId' => $data['rowIds'][$key], 'description' => $data['rowIds'][$key], 'name' => $value, 'price' => $data['prices'][$key], 'quantity' => $data['quantities'][$key], 'selectedVat' => $vat, 'selectedArticle' => $article, 'selectedUom' => $uom, 'total' => $data['totals'][$key], 'vatAmount' => $data['vatAmounts'][$key], 'vatValue' => $data['vatValues'][$key]); $invoiceRows[] = $rowArray; } return $invoiceRows; }
public function deleteUomAction() { if ($this->request->isGet() && $this->request->isXmlHttpRequest()) { $pieces = explode("-", $this->request->getQuery()->id); $uom = $this->settingsService->getUomById($pieces[1]); if ($uom) { $this->settingsService->deleteUom($uom); return new JsonModel(array($pieces[1])); } else { return new JsonModel(array()); } } return $this->response; }