deletable sell records

This commit is contained in:
Kayn Ty 2018-05-24 16:11:03 +02:00
parent ff118f64a6
commit 9a97f7312d
No known key found for this signature in database
GPG Key ID: 55B09AA0ED327CD3
3 changed files with 62 additions and 63 deletions

View File

@ -7,16 +7,6 @@
<div class="row">
<h1>Historique</h1>
</div>
<h2>Ventes de produits</h2>
<div id="chartContainer" style="display: inline-block; height: 300px; width: 49%;"></div>
<div id="chartContainerChiffreAffaire" style="display: inline-block; height: 300px; width: 49%;"></div>
<h2> {{ statisticsFestivals |length }} Festival
{% if statisticsFestivals |length >1 %}
s
{% endif %}</h2>
<div id="chartContainerstatisticsFestivals"
style="display: inline-block; height: 300px; width: 100%;"></div>
<div class="row">
<div class="col-xs-6">
<div class="sells">
@ -51,8 +41,7 @@
{% endif %}
</span>
panier moyen
€ panier moyen
</h2>
</div>
@ -68,6 +57,24 @@
<i class="fa fa-file-o fa-3x"></i>
Exporter toutes vos données en format csv
</a>
</div>
</div>
<hr>
<h2 class="text-center">Statistiques de ventes </h2>
<div id="chartContainer" style="display: inline-block; height: 300px; width: 49%;"></div>
<div id="chartContainerChiffreAffaire" style="display: inline-block; height: 300px; width: 49%;"></div>
<h2> {{ statisticsFestivals |length }} Festival
{% if statisticsFestivals |length >1 %}
s
{% endif %}</h2>
<div id="chartContainerstatisticsFestivals"
style="display: inline-block; height: 300px; width: 100%;"></div>
</div>
</div>
<div id="last-sellings">
<h2>
{{ recentSells |length }} Dernières ventes
</h2>
@ -102,7 +109,8 @@
<div class="col-xs-3">
{{ vente.amount }}
<a href="{{ path('sellrecord_delete',{id: vente.id}) }}" class="btn btn-warning pull-right">
<a href="{{ path('sellrecord_delete',{id: vente.id }) }}"
class="btn btn-warning pull-right">
<i class="fa fa-trash"></i>
</a>
</div>
@ -110,11 +118,6 @@
{% endfor %}
</div>
</div>
</div>
</div>
{% include ':logged:history-script.html.twig' %}

View File

@ -8,6 +8,8 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
/**
* Sellrecord controller.
*
@ -106,27 +108,21 @@ class SellRecordController extends Controller {
'delete_form' => $deleteForm->createView(),
] );
}
/**
* Deletes a sellRecord entity.
*
* @Route("/{id}", name="sellrecord_delete")
* @Method("DELETE")
* @Route("/delete/{id}", name="sellrecord_delete")
*/
public function deleteAction( Request $request, SellRecord $sellRecord ) {
public function deleteAction( Request $request, SellRecord $id) {
$sellRecord = $id;
if ( $sellRecord->getUser()->getId() !== $this->getUser()->getId() ) {
$this->denyAccessUnlessGranted( 'ROLE_ADMIN' );
}
$form = $this->createDeleteForm( $sellRecord );
$form->handleRequest( $request );
if ( $form->isSubmitted() && $form->isValid() ) {
$em = $this->getDoctrine()->getManager();
$em->remove( $sellRecord );
$em->flush();
}
return $this->redirectToRoute( 'sellrecord_index' );
return $this->redirectToRoute( 'history' );
}
/**

View File

@ -24,7 +24,7 @@ class SellRecord {
private $gender;
/**
* liste des produits de la vente
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="sellRecords")
* @ORM\OneToMany(targetEntity="AppBundle\Entity\ProductSold", mappedBy="sellRecords", cascade={"remove", "persist","detach"})
*/
private $productsSold;