crud serie of festival
This commit is contained in:
parent
bb7f8680fc
commit
bee4a85673
|
@ -69,6 +69,22 @@
|
|||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn {% if app.request.attributes.get('_route') == 'seriefestival_index' %}
|
||||
btn-success
|
||||
{% else %}
|
||||
btn-default
|
||||
{% endif %}
|
||||
" href='{{ path('seriefestival_index') }}'
|
||||
>
|
||||
<i class="fa fa-th-large"></i>
|
||||
|
||||
{% trans %}menu.series{% endtrans %}
|
||||
<span class="badge">
|
||||
{{ app.user.seriesFestivals|length }}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn {% if app.request.attributes.get('_route') == 'history' %}
|
||||
btn-success
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% verbatim %}
|
||||
<div id="not_loaded" ng-if="!initLoadDone">
|
||||
<div class="well">
|
||||
<div class="well text-center">
|
||||
<i class="fa fa-refresh fa-spin fa-3x"></i> Chargement en cours de vos produits
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Seriefestival edit</h1>
|
||||
|
||||
{{ form_start(edit_form) }}
|
||||
{{ form_widget(edit_form) }}
|
||||
<input type="submit" value="Edit" />
|
||||
{{ form_end(edit_form) }}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('seriefestival_index') }}">Back to the list</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_start(delete_form) }}
|
||||
<input type="submit" value="Delete">
|
||||
{{ form_end(delete_form) }}
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
|
@ -0,0 +1,55 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<div class="row heading-of-list">
|
||||
<div class="col-xs-6">
|
||||
<h1>Série de Festivals</h1>
|
||||
<div class="well">
|
||||
une série de festival vous permet d'obtenir des statistiques sur plusieurs évènements à la fois. et de comparer
|
||||
des coûts et bénéfices d'une édition à une autre.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<a class="btn btn-primary" href="{{ path('seriefestival_new') }}">Nouvelle série</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Datecreation</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for serieFestival in serieFestivals %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ path('seriefestival_show', { 'id': serieFestival.id }) }}">{{ serieFestival.id }}</a>
|
||||
</td>
|
||||
<td>{{ serieFestival.name }}</td>
|
||||
<td>{% if serieFestival.dateCreation %}{{ serieFestival.dateCreation|date('Y-m-d H:i:s') }}{% endif %}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('seriefestival_show', { 'id': serieFestival.id }) }}">show</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('seriefestival_edit', { 'id': serieFestival.id }) }}">edit</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a class="btn btn-primary" href="{{ path('seriefestival_new') }}">Nouvelle série</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
|
@ -0,0 +1,16 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Création de série de festival</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<input type="submit" value="Create"/>
|
||||
{{ form_end(form) }}
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('seriefestival_index') }}">Retour à la liste</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
|
@ -0,0 +1,36 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Seriefestival</h1>
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ serieFestival.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>{{ serieFestival.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Datecreation</th>
|
||||
<td>{% if serieFestival.dateCreation %}{{ serieFestival.dateCreation|date('Y-m-d H:i:s') }}{% endif %}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('seriefestival_index') }}">Back to the list</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('seriefestival_edit', { 'id': serieFestival.id }) }}">Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_start(delete_form) }}
|
||||
<input type="submit" value="Delete">
|
||||
{{ form_end(delete_form) }}
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
|
@ -1,3 +1,7 @@
|
|||
app_serie_festival:
|
||||
resource: "@AppBundle/Controller/SerieFestivalController.php"
|
||||
type: annotation
|
||||
|
||||
|
||||
fos_user_profile:
|
||||
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
|
||||
|
|
|
@ -91,3 +91,7 @@
|
|||
margin-left: 1em;
|
||||
}
|
||||
}
|
||||
#not_loaded{
|
||||
width: 100%;
|
||||
height: 75vh;
|
||||
}
|
||||
|
|
|
@ -64,9 +64,10 @@ body {
|
|||
height: 4em;
|
||||
padding: 1em;
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
position: static;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
thead {
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Entity\SerieFestival;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Seriefestival controller.
|
||||
*
|
||||
* @Route("seriefestival")
|
||||
*/
|
||||
class SerieFestivalController extends Controller
|
||||
{
|
||||
/**
|
||||
* Lists all serieFestival entities.
|
||||
*
|
||||
* @Route("/", name="seriefestival_index")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$serieFestivals = $em->getRepository('AppBundle:SerieFestival')->findAll();
|
||||
|
||||
return $this->render('seriefestival/index.html.twig', array(
|
||||
'serieFestivals' => $serieFestivals,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new serieFestival entity.
|
||||
*
|
||||
* @Route("/new", name="seriefestival_new")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function newAction(Request $request)
|
||||
{
|
||||
$usr= $this->getUser();
|
||||
|
||||
$serieFestival = new Seriefestival();
|
||||
$serieFestival->setUser($usr);
|
||||
|
||||
$form = $this->createForm('AppBundle\Form\SerieFestivalType', $serieFestival);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($serieFestival);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirectToRoute('seriefestival_show', array('id' => $serieFestival->getId()));
|
||||
}
|
||||
|
||||
return $this->render('seriefestival/new.html.twig', array(
|
||||
'serieFestival' => $serieFestival,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and displays a serieFestival entity.
|
||||
*
|
||||
* @Route("/{id}", name="seriefestival_show")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function showAction(SerieFestival $serieFestival)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($serieFestival);
|
||||
|
||||
return $this->render('seriefestival/show.html.twig', array(
|
||||
'serieFestival' => $serieFestival,
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing serieFestival entity.
|
||||
*
|
||||
* @Route("/{id}/edit", name="seriefestival_edit")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function editAction(Request $request, SerieFestival $serieFestival)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($serieFestival);
|
||||
$editForm = $this->createForm('AppBundle\Form\SerieFestivalType', $serieFestival);
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('seriefestival_edit', array('id' => $serieFestival->getId()));
|
||||
}
|
||||
|
||||
return $this->render('seriefestival/edit.html.twig', array(
|
||||
'serieFestival' => $serieFestival,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a serieFestival entity.
|
||||
*
|
||||
* @Route("/{id}", name="seriefestival_delete")
|
||||
* @Method("DELETE")
|
||||
*/
|
||||
public function deleteAction(Request $request, SerieFestival $serieFestival)
|
||||
{
|
||||
$form = $this->createDeleteForm($serieFestival);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($serieFestival);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('seriefestival_index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to delete a serieFestival entity.
|
||||
*
|
||||
* @param SerieFestival $serieFestival The serieFestival entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm(SerieFestival $serieFestival)
|
||||
{
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('seriefestival_delete', array('id' => $serieFestival->getId())))
|
||||
->setMethod('DELETE')
|
||||
->getForm()
|
||||
;
|
||||
}
|
||||
}
|
|
@ -87,7 +87,11 @@ class Festival {
|
|||
private $fraisRepas;
|
||||
|
||||
|
||||
/**
|
||||
public function __toString() {
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSerieFestival()
|
||||
|
@ -130,7 +134,7 @@ class Festival {
|
|||
'fondDeCaisseApres' => $this->getFondDeCaisseApres(),
|
||||
'sold' => $soldItems,
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
public function recalculateChiffreAffaire() {
|
||||
$sellings = $this->getSellRecords();
|
||||
|
|
|
@ -12,7 +12,13 @@ class FestivalType extends AbstractType {
|
|||
*/
|
||||
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||
$builder
|
||||
->add( 'name' )
|
||||
->add( 'name',
|
||||
null,
|
||||
[
|
||||
'attr' => [
|
||||
'autofocus' => true,
|
||||
],
|
||||
] )
|
||||
->add( 'fraisInscription' )
|
||||
->add( 'fraisTransport' )
|
||||
->add( 'fraisHebergement' )
|
||||
|
|
|
@ -6,33 +6,36 @@ use Symfony\Component\Form\AbstractType;
|
|||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ProductCategoryType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('name')
|
||||
// ->add('users')
|
||||
;
|
||||
}/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'AppBundle\Entity\ProductCategory'
|
||||
));
|
||||
}
|
||||
class ProductCategoryType extends AbstractType {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||
$builder->add( 'name',
|
||||
null,
|
||||
[
|
||||
'attr' => [
|
||||
'autofocus' => true,
|
||||
],
|
||||
] )// ->add('users')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'appbundle_productcategory';
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions( OptionsResolver $resolver ) {
|
||||
$resolver->setDefaults( [
|
||||
'data_class' => 'AppBundle\Entity\ProductCategory',
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix() {
|
||||
return 'appbundle_productcategory';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,13 +23,20 @@ class ProductType extends AbstractType {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||
$builder->add( 'name' , null, ['label'=>'Nom'])
|
||||
$builder->add( 'name',
|
||||
null,
|
||||
[
|
||||
'label' => 'Nom',
|
||||
'attr' => [
|
||||
'autofocus' => true,
|
||||
],
|
||||
] )
|
||||
->add( 'image',
|
||||
null,
|
||||
[ 'label' => 'URL pour image' ] )
|
||||
->add( 'stockCount', null, ['label'=>'En stock'] )
|
||||
->add( 'price', null, ['label'=>'Prix en euros'])
|
||||
->add( 'comment', null, ['label'=>'Commentaire']);
|
||||
->add( 'stockCount', null, [ 'label' => 'En stock' ] )
|
||||
->add( 'price', null, [ 'label' => 'Prix en euros' ] )
|
||||
->add( 'comment', null, [ 'label' => 'Commentaire' ] );
|
||||
$user = $this->security->getUser();
|
||||
if ( ! $user ) {
|
||||
throw new \LogicException(
|
||||
|
@ -46,10 +53,10 @@ class ProductType extends AbstractType {
|
|||
$form->add( 'category',
|
||||
EntityType::class,
|
||||
[
|
||||
'class' => 'AppBundle:ProductCategory',
|
||||
'class' => 'AppBundle:ProductCategory',
|
||||
'placeholder' => '--- catégories ---',
|
||||
'choices' => $categories,
|
||||
'label' => 'Catégorie',
|
||||
'choices' => $categories,
|
||||
'label' => 'Catégorie',
|
||||
] );
|
||||
} );
|
||||
|
||||
|
|
|
@ -22,7 +22,14 @@ class SellRecordType extends AbstractType {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||
$builder->add( 'products' );
|
||||
$builder->add( 'products' )
|
||||
->add('comment',
|
||||
null,
|
||||
[
|
||||
'attr' => [
|
||||
'autofocus' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Form;
|
||||
|
||||
use AppBundle\Entity\Festival;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class SerieFestivalType extends AbstractType {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||
$builder->add( 'name',
|
||||
null,
|
||||
[
|
||||
'attr' => [
|
||||
'autofocus' => true,
|
||||
],
|
||||
] )
|
||||
->add( 'dateCreation',
|
||||
DateType::class,
|
||||
[
|
||||
// renders it as a single text box
|
||||
'widget' => 'single_text',
|
||||
] )
|
||||
->add( 'festivals', EntityType::class, [ 'class' => Festival::class, 'multiple' => true ] )
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions( OptionsResolver $resolver ) {
|
||||
$resolver->setDefaults( [
|
||||
'data_class' => 'AppBundle\Entity\SerieFestival',
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix() {
|
||||
return 'appbundle_seriefestival';
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class SerieFestivalControllerTest extends WebTestCase
|
||||
{
|
||||
/*
|
||||
public function testCompleteScenario()
|
||||
{
|
||||
// Create a new client to browse the application
|
||||
$client = static::createClient();
|
||||
|
||||
// Create a new entry in the database
|
||||
$crawler = $client->request('GET', '/seriefestival/');
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /seriefestival/");
|
||||
$crawler = $client->click($crawler->selectLink('Create a new entry')->link());
|
||||
|
||||
// Fill in the form and submit it
|
||||
$form = $crawler->selectButton('Create')->form(array(
|
||||
'appbundle_seriefestival[field_name]' => 'Test',
|
||||
// ... other fields to fill
|
||||
));
|
||||
|
||||
$client->submit($form);
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check data in the show view
|
||||
$this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")');
|
||||
|
||||
// Edit the entity
|
||||
$crawler = $client->click($crawler->selectLink('Edit')->link());
|
||||
|
||||
$form = $crawler->selectButton('Update')->form(array(
|
||||
'appbundle_seriefestival[field_name]' => 'Foo',
|
||||
// ... other fields to fill
|
||||
));
|
||||
|
||||
$client->submit($form);
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check the element contains an attribute with value equals "Foo"
|
||||
$this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]');
|
||||
|
||||
// Delete the entity
|
||||
$client->submit($crawler->selectButton('Delete')->form());
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
// Check the entity has been delete on the list
|
||||
$this->assertNotRegExp('/Foo/', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
|
@ -8,6 +8,7 @@ menu:
|
|||
history: History
|
||||
import: Import
|
||||
festivals: Festivals
|
||||
series: Séries
|
||||
products: Products
|
||||
categories: Categories
|
||||
future: Forecast
|
||||
|
|
|
@ -7,6 +7,7 @@ menu:
|
|||
history: Historique
|
||||
import: Importer
|
||||
festivals: Festivals
|
||||
series: Séries
|
||||
products: Produits
|
||||
categories: Catégories
|
||||
future: Prévisionnel
|
||||
|
|
Loading…
Reference in New Issue