예제 #1
0
 public function saveArticle($post, Categorie $categorie, Auteur $auteur)
 {
     $articleToSave = new Article();
     $date = new \DateTime('now', new \DateTimeZone('UTC'));
     try {
         $articleToSave->setAuteur($auteur);
         $articleToSave->setCategorie($categorie);
         $articleToSave->setTitre($post["titre"]);
         $articleToSave->setContenu($post["contenu"]);
         $articleToSave->setDate($date);
         $articleToSave->setChapeau("c");
         $articleToSave->setEn_ligne(isset($post["en_ligne"]) ? true : false);
         $this->em->persist($articleToSave);
         $this->em->flush();
     } catch (\Exception $e) {
         $this->getServiceLocator()->get('Zend\\LogError')->err('Erreur au moment de sauvegarder un article');
         throw $e;
     }
 }
예제 #2
0
 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;
 }
예제 #3
0
 public function addArticle(Article $article)
 {
     $this->articles[] = $article;
     $article->setUser($this);
 }
예제 #4
0
 public function setFormValues(Article $article = null)
 {
     if ($article) {
         $this->get('name')->setValue($article->getName());
         $this->get('code')->setValue($article->getCode());
         $this->get('salesPrice')->setValue($article->getSalesPrice());
         $this->get('qty')->setValue($article->getQuantity());
         $this->get('description')->setValue($article->getDescription());
         if ($article->getUom()) {
             $this->get('uom')->setValue($article->getUom()->getId());
         }
     }
 }
예제 #5
0
 public function getArticlesByCodeOrName(User $user, $value)
 {
     return $this->entityManager->getRepository(Article::getClass())->getArticlesByCodeOrName($user, $value);
 }
 /**
  * {@inheritDoc}
  */
 public function setEn_ligne($en_ligne)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setEn_ligne', array($en_ligne));
     return parent::setEn_ligne($en_ligne);
 }