update crud

This commit is contained in:
Kayn Ty 2018-05-24 15:11:18 +02:00
parent 975adbb340
commit 9aa584dbcb
No known key found for this signature in database
GPG Key ID: 55B09AA0ED327CD3
11 changed files with 162 additions and 10 deletions

View File

@ -5,7 +5,7 @@
<div class="col-xs-6"> <div class="col-xs-6">
<h1>Produits</h1></div> <h1>Produits</h1></div>
<div class="col-xs-6"> <div class="col-xs-6">
<a class="btn btn-primary" href="{{ path('product_new') }}">Nouveau produit</a> <a class="btn btn-primary pull-right" href="{{ path('product_new') }}">Nouveau produit</a>
</div> </div>
</div> </div>
@ -27,11 +27,22 @@
{% for product in products %} {% for product in products %}
<tr> <tr>
<td> <td>
<a class="btn btn-primary" <a class="btn btn-primary btn-block"
href="{{ path('product_show', { 'id': product.id }) }}">{{ product.id }}</a> href="{{ path('product_show', { 'id': product.id }) }}">{{ product.id }}</a>
</td> </td>
<td>{{ product.category.name }}</td> <td>
<td>{{ product.name }}</td> <a class="btn btn-primary btn-block"
href="{{ path('productcategory_edit', { 'id': product.category.id }) }}">
{{ product.category.name }}
</a>
</td>
<td>
<a class="btn btn-default btn-block" href="{{ path('product_edit', { 'id': product.id }) }}">
{{ product.name }}
</a>
</td>
<td>{{ product.image }}</td> <td>{{ product.image }}</td>
<td>{{ product.price }}</td> <td>{{ product.price }}</td>
<td>{{ product.stockCount }}</td> <td>{{ product.stockCount }}</td>
@ -46,9 +57,5 @@
</tbody> </tbody>
</table> </table>
<ul> <a class="btn btn-primary" href="{{ path('product_new') }}">Nouveau produit</a>
<li>
<a class="btn btn-primary" href="{{ path('product_new') }}">Nouveau produit</a>
</li>
</ul>
{% endblock %} {% endblock %}

View File

@ -16,6 +16,7 @@
<th>Id</th> <th>Id</th>
<th>Nom</th> <th>Nom</th>
<th>Produits</th> <th>Produits</th>
<th>Vendus</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
@ -26,8 +27,12 @@
<a class="btn btn-primary" <a class="btn btn-primary"
href="{{ path('productcategory_show', { 'id': productCategory.id }) }}">{{ productCategory.id }}</a> href="{{ path('productcategory_show', { 'id': productCategory.id }) }}">{{ productCategory.id }}</a>
</td> </td>
<td>{{ productCategory.name }}</td> <td><a class="btn btn-default btn-block"
href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}">
{{ productCategory.name }}
</a></td>
<td>{{ productCategory.products|length }}</td> <td>{{ productCategory.products|length }}</td>
<td>{{ productCategory.productsSold|length }}</td>
<td> <td>
<a class="btn btn-primary" <a class="btn btn-primary"
href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}"> href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}">

0
src/AppBundle/Entity/Festival.php Executable file → Normal file
View File

View File

@ -83,6 +83,23 @@ class Festival {
private $fraisRepas; 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() { public function recalculateChiffreAffaire() {
$sellings = $this->getSellRecords(); $sellings = $this->getSellRecords();
$newChiffreAffaire = 0; $newChiffreAffaire = 0;

0
src/AppBundle/Entity/Product.php Executable file → Normal file
View File

40
src/AppBundle/Entity/ProductCategory.php Executable file → Normal file
View File

@ -24,6 +24,10 @@ class ProductCategory {
* @ORM\OneToMany(targetEntity="Product", mappedBy="category") * @ORM\OneToMany(targetEntity="Product", mappedBy="category")
*/ */
private $products; private $products;
/**
* @ORM\OneToMany(targetEntity="ProductSold", mappedBy="product")
*/
private $productsSold;
/** /**
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", mappedBy="categories") * @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", mappedBy="categories")
@ -155,4 +159,40 @@ class ProductCategory {
public function removeUser( \AppBundle\Entity\User $user ) { public function removeUser( \AppBundle\Entity\User $user ) {
$this->users->removeElement( $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;
}
} }

View File

@ -24,6 +24,10 @@ class ProductCategory {
* @ORM\OneToMany(targetEntity="Product", mappedBy="category") * @ORM\OneToMany(targetEntity="Product", mappedBy="category")
*/ */
private $products; private $products;
/**
* @ORM\OneToMany(targetEntity="ProductSold", mappedBy="product")
*/
private $productsSold;
/** /**
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", mappedBy="categories") * @ORM\ManyToMany(targetEntity="AppBundle\Entity\User", mappedBy="categories")
@ -34,6 +38,21 @@ class ProductCategory {
return $this->getName() . ' (' . count( $this->getProducts() ) . ' produits)'; 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 * @return mixed
*/ */
@ -140,4 +159,40 @@ class ProductCategory {
public function removeUser( \AppBundle\Entity\User $user ) { public function removeUser( \AppBundle\Entity\User $user ) {
$this->users->removeElement( $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;
}
} }

0
src/AppBundle/Entity/ProductSold.php Executable file → Normal file
View File

0
src/AppBundle/Entity/SellRecord.php Executable file → Normal file
View File

0
src/AppBundle/Entity/User.php Executable file → Normal file
View File

View File

@ -127,6 +127,34 @@ class User extends BaseUser {
$this->googleAccessToken = $googleAccessToken; $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 * @return mixed
*/ */