update crud
This commit is contained in:
parent
975adbb340
commit
9aa584dbcb
@ -5,7 +5,7 @@
|
||||
<div class="col-xs-6">
|
||||
<h1>Produits</h1></div>
|
||||
<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>
|
||||
|
||||
@ -27,11 +27,22 @@
|
||||
{% for product in products %}
|
||||
<tr>
|
||||
<td>
|
||||
<a class="btn btn-primary"
|
||||
<a class="btn btn-primary btn-block"
|
||||
href="{{ path('product_show', { 'id': product.id }) }}">{{ product.id }}</a>
|
||||
</td>
|
||||
<td>{{ product.category.name }}</td>
|
||||
<td>{{ product.name }}</td>
|
||||
<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.price }}</td>
|
||||
<td>{{ product.stockCount }}</td>
|
||||
@ -46,9 +57,5 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a class="btn btn-primary" href="{{ path('product_new') }}">Nouveau produit</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="btn btn-primary" href="{{ path('product_new') }}">Nouveau produit</a>
|
||||
{% endblock %}
|
||||
|
@ -16,6 +16,7 @@
|
||||
<th>Id</th>
|
||||
<th>Nom</th>
|
||||
<th>Produits</th>
|
||||
<th>Vendus</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -26,8 +27,12 @@
|
||||
<a class="btn btn-primary"
|
||||
href="{{ path('productcategory_show', { 'id': productCategory.id }) }}">{{ productCategory.id }}</a>
|
||||
</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.productsSold|length }}</td>
|
||||
<td>
|
||||
<a class="btn btn-primary"
|
||||
href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}">
|
||||
|
0
src/AppBundle/Entity/Festival.php
Executable file → Normal file
0
src/AppBundle/Entity/Festival.php
Executable file → Normal file
@ -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;
|
||||
|
0
src/AppBundle/Entity/Product.php
Executable file → Normal file
0
src/AppBundle/Entity/Product.php
Executable file → Normal file
40
src/AppBundle/Entity/ProductCategory.php
Executable file → Normal file
40
src/AppBundle/Entity/ProductCategory.php
Executable file → Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
0
src/AppBundle/Entity/ProductSold.php
Executable file → Normal file
0
src/AppBundle/Entity/ProductSold.php
Executable file → Normal file
0
src/AppBundle/Entity/SellRecord.php
Executable file → Normal file
0
src/AppBundle/Entity/SellRecord.php
Executable file → Normal file
0
src/AppBundle/Entity/User.php
Executable file → Normal file
0
src/AppBundle/Entity/User.php
Executable file → Normal file
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user