diff --git a/app/Resources/views/product/index.html.twig b/app/Resources/views/product/index.html.twig index aa5e1f46..c0e992d3 100755 --- a/app/Resources/views/product/index.html.twig +++ b/app/Resources/views/product/index.html.twig @@ -5,7 +5,7 @@

Produits

- Nouveau produit + Nouveau produit
@@ -27,11 +27,22 @@ {% for product in products %} - {{ product.id }} - {{ product.category.name }} - {{ product.name }} + + + {{ product.category.name }} + + + + + + + {{ product.name }} + + {{ product.image }} {{ product.price }} {{ product.stockCount }} @@ -46,9 +57,5 @@ - + Nouveau produit {% endblock %} diff --git a/app/Resources/views/productcategory/index.html.twig b/app/Resources/views/productcategory/index.html.twig index 59a9e182..71c42653 100755 --- a/app/Resources/views/productcategory/index.html.twig +++ b/app/Resources/views/productcategory/index.html.twig @@ -16,6 +16,7 @@ Id Nom Produits + Vendus Actions @@ -26,8 +27,12 @@ {{ productCategory.id }} - {{ productCategory.name }} + + {{ productCategory.name }} + {{ productCategory.products|length }} + {{ productCategory.productsSold|length }} diff --git a/src/AppBundle/Entity/Festival.php b/src/AppBundle/Entity/Festival.php old mode 100755 new mode 100644 diff --git a/src/AppBundle/Entity/Festival.php~ b/src/AppBundle/Entity/Festival.php~ index e2c7207a..e694c66d 100755 --- a/src/AppBundle/Entity/Festival.php~ +++ b/src/AppBundle/Entity/Festival.php~ @@ -83,6 +83,23 @@ class Festival { private $fraisRepas; + /** + * array usable by js + * @return array + */ + public function makeArray(){ + return [ + 'id' => $this->getId(), + 'name' => $this->getName(), + 'commentaire' => $this->getComment(), + 'dateCreation' => $this->getDateCreation(), + 'chiffreAffaire' => $this->getChiffreAffaire(), + 'clientsCount' => count($this->getSellRecords()), + 'fondDeCaisseAvant' => $this->getFondDeCaisseAvant(), + 'fondDeCaisseApres' => $this->getFondDeCaisseApres(), + ]; + + } public function recalculateChiffreAffaire() { $sellings = $this->getSellRecords(); $newChiffreAffaire = 0; diff --git a/src/AppBundle/Entity/Product.php b/src/AppBundle/Entity/Product.php old mode 100755 new mode 100644 diff --git a/src/AppBundle/Entity/ProductCategory.php b/src/AppBundle/Entity/ProductCategory.php old mode 100755 new mode 100644 index 3a2495ab..3602a35b --- a/src/AppBundle/Entity/ProductCategory.php +++ b/src/AppBundle/Entity/ProductCategory.php @@ -24,6 +24,10 @@ class ProductCategory { * @ORM\OneToMany(targetEntity="Product", mappedBy="category") */ private $products; + /** + * @ORM\OneToMany(targetEntity="ProductSold", mappedBy="product") + */ + private $productsSold; /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", mappedBy="categories") @@ -155,4 +159,40 @@ class ProductCategory { public function removeUser( \AppBundle\Entity\User $user ) { $this->users->removeElement( $user ); } + + /** + * Add productsSold. + * + * @param \AppBundle\Entity\ProductSold $productsSold + * + * @return ProductCategory + */ + public function addProductsSold(\AppBundle\Entity\ProductSold $productsSold) + { + $this->productsSold[] = $productsSold; + + return $this; + } + + /** + * Remove productsSold. + * + * @param \AppBundle\Entity\ProductSold $productsSold + * + * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. + */ + public function removeProductsSold(\AppBundle\Entity\ProductSold $productsSold) + { + return $this->productsSold->removeElement($productsSold); + } + + /** + * Get productsSold. + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getProductsSold() + { + return $this->productsSold; + } } diff --git a/src/AppBundle/Entity/ProductCategory.php~ b/src/AppBundle/Entity/ProductCategory.php~ index a9539cd3..3602a35b 100755 --- a/src/AppBundle/Entity/ProductCategory.php~ +++ b/src/AppBundle/Entity/ProductCategory.php~ @@ -24,6 +24,10 @@ class ProductCategory { * @ORM\OneToMany(targetEntity="Product", mappedBy="category") */ private $products; + /** + * @ORM\OneToMany(targetEntity="ProductSold", mappedBy="product") + */ + private $productsSold; /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", mappedBy="categories") @@ -34,6 +38,21 @@ class ProductCategory { return $this->getName() . ' (' . count( $this->getProducts() ) . ' produits)'; } + /** + * @param $userId + * + * @return bool + */ + public function hasUser( $userId ) { + foreach ( $this->getUsers() as $user ) { + if ( $user->getId() === $userId ) { + return true; + } + } + + return false; + } + /** * @return mixed */ @@ -140,4 +159,40 @@ class ProductCategory { public function removeUser( \AppBundle\Entity\User $user ) { $this->users->removeElement( $user ); } + + /** + * Add productsSold. + * + * @param \AppBundle\Entity\ProductSold $productsSold + * + * @return ProductCategory + */ + public function addProductsSold(\AppBundle\Entity\ProductSold $productsSold) + { + $this->productsSold[] = $productsSold; + + return $this; + } + + /** + * Remove productsSold. + * + * @param \AppBundle\Entity\ProductSold $productsSold + * + * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. + */ + public function removeProductsSold(\AppBundle\Entity\ProductSold $productsSold) + { + return $this->productsSold->removeElement($productsSold); + } + + /** + * Get productsSold. + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getProductsSold() + { + return $this->productsSold; + } } diff --git a/src/AppBundle/Entity/ProductSold.php b/src/AppBundle/Entity/ProductSold.php old mode 100755 new mode 100644 diff --git a/src/AppBundle/Entity/SellRecord.php b/src/AppBundle/Entity/SellRecord.php old mode 100755 new mode 100644 diff --git a/src/AppBundle/Entity/User.php b/src/AppBundle/Entity/User.php old mode 100755 new mode 100644 diff --git a/src/AppBundle/Entity/User.php~ b/src/AppBundle/Entity/User.php~ index bcb5255b..ac9ae139 100755 --- a/src/AppBundle/Entity/User.php~ +++ b/src/AppBundle/Entity/User.php~ @@ -127,6 +127,34 @@ class User extends BaseUser { $this->googleAccessToken = $googleAccessToken; } + /** + * @return mixed + */ + public function getDisqusAccessToken() { + return $this->disqusAccessToken; + } + + /** + * @param mixed $disqusAccessToken + */ + public function setDisqusAccessToken( $disqusAccessToken ) { + $this->disqusAccessToken = $disqusAccessToken; + } + + /** + * @return mixed + */ + public function getTwitterAccessToken() { + return $this->twitterAccessToken; + } + + /** + * @param mixed $twitterAccessToken + */ + public function setTwitterAccessToken( $TwitterAccessToken ) { + $this->twitterAccessToken = $TwitterAccessToken; + } + /** * @return mixed */