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"> <div class="row">
<h1>Historique</h1> <h1>Historique</h1>
</div> </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="row">
<div class="col-xs-6"> <div class="col-xs-6">
<div class="sells"> <div class="sells">
@ -51,8 +41,7 @@
{% endif %} {% endif %}
</span> </span>
€ panier moyen
panier moyen
</h2> </h2>
</div> </div>
@ -68,6 +57,24 @@
<i class="fa fa-file-o fa-3x"></i> <i class="fa fa-file-o fa-3x"></i>
Exporter toutes vos données en format csv Exporter toutes vos données en format csv
</a> </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> <h2>
{{ recentSells |length }} Dernières ventes {{ recentSells |length }} Dernières ventes
</h2> </h2>
@ -102,7 +109,8 @@
<div class="col-xs-3"> <div class="col-xs-3">
{{ vente.amount }} {{ 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> <i class="fa fa-trash"></i>
</a> </a>
</div> </div>
@ -110,11 +118,6 @@
{% endfor %} {% endfor %}
</div> </div>
</div>
</div>
</div>
{% include ':logged:history-script.html.twig' %} {% 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\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
/** /**
* Sellrecord controller. * Sellrecord controller.
* *
@ -106,27 +108,21 @@ class SellRecordController extends Controller {
'delete_form' => $deleteForm->createView(), 'delete_form' => $deleteForm->createView(),
] ); ] );
} }
/** /**
* Deletes a sellRecord entity. * Deletes a sellRecord entity.
* *
* @Route("/{id}", name="sellrecord_delete") * @Route("/delete/{id}", name="sellrecord_delete")
* @Method("DELETE")
*/ */
public function deleteAction( Request $request, SellRecord $sellRecord ) { public function deleteAction( Request $request, SellRecord $id) {
$sellRecord = $id;
if ( $sellRecord->getUser()->getId() !== $this->getUser()->getId() ) { if ( $sellRecord->getUser()->getId() !== $this->getUser()->getId() ) {
$this->denyAccessUnlessGranted( 'ROLE_ADMIN' ); $this->denyAccessUnlessGranted( 'ROLE_ADMIN' );
} }
$form = $this->createDeleteForm( $sellRecord );
$form->handleRequest( $request );
if ( $form->isSubmitted() && $form->isValid() ) {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->remove( $sellRecord ); $em->remove( $sellRecord );
$em->flush(); $em->flush();
}
return $this->redirectToRoute( 'sellrecord_index' ); return $this->redirectToRoute( 'history' );
} }
/** /**

View File

@ -24,7 +24,7 @@ class SellRecord {
private $gender; private $gender;
/** /**
* liste des produits de la vente * 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; private $productsSold;