diff --git a/app/Resources/views/default/login-choices.html.twig b/app/Resources/views/default/login-choices.html.twig index 2d9a8e8c..694638e5 100755 --- a/app/Resources/views/default/login-choices.html.twig +++ b/app/Resources/views/default/login-choices.html.twig @@ -69,6 +69,22 @@ +
  • + + + + {% trans %}menu.series{% endtrans %} + + {{ app.user.seriesFestivals|length }} + + +
  • -
    +
    Chargement en cours de vos produits
    diff --git a/app/Resources/views/seriefestival/edit.html.twig b/app/Resources/views/seriefestival/edit.html.twig new file mode 100644 index 00000000..9c3f575a --- /dev/null +++ b/app/Resources/views/seriefestival/edit.html.twig @@ -0,0 +1,21 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

    Seriefestival edit

    + + {{ form_start(edit_form) }} + {{ form_widget(edit_form) }} + + {{ form_end(edit_form) }} + +
    +{% endblock %} diff --git a/app/Resources/views/seriefestival/index.html.twig b/app/Resources/views/seriefestival/index.html.twig new file mode 100644 index 00000000..d76570ee --- /dev/null +++ b/app/Resources/views/seriefestival/index.html.twig @@ -0,0 +1,55 @@ +{% extends 'base.html.twig' %} + +{% block body %} +
    +
    +

    Série de Festivals

    +
    + 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. +
    +
    + +
    + + + + + + + + + + + + {% for serieFestival in serieFestivals %} + + + + + + + {% endfor %} + +
    IdNameDatecreationActions
    + {{ serieFestival.id }} + {{ serieFestival.name }}{% if serieFestival.dateCreation %}{{ serieFestival.dateCreation|date('Y-m-d H:i:s') }}{% endif %} + +
    + + +{% endblock %} diff --git a/app/Resources/views/seriefestival/new.html.twig b/app/Resources/views/seriefestival/new.html.twig new file mode 100644 index 00000000..ac0b7e51 --- /dev/null +++ b/app/Resources/views/seriefestival/new.html.twig @@ -0,0 +1,16 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

    Création de série de festival

    + + {{ form_start(form) }} + {{ form_widget(form) }} + + {{ form_end(form) }} + + +{% endblock %} diff --git a/app/Resources/views/seriefestival/show.html.twig b/app/Resources/views/seriefestival/show.html.twig new file mode 100644 index 00000000..604ecd06 --- /dev/null +++ b/app/Resources/views/seriefestival/show.html.twig @@ -0,0 +1,36 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

    Seriefestival

    + + + + + + + + + + + + + + + + +
    Id{{ serieFestival.id }}
    Name{{ serieFestival.name }}
    Datecreation{% if serieFestival.dateCreation %}{{ serieFestival.dateCreation|date('Y-m-d H:i:s') }}{% endif %}
    + + +{% endblock %} diff --git a/app/config/routing.yml b/app/config/routing.yml index 1882e91d..c8dfe125 100755 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -1,3 +1,7 @@ +app_serie_festival: + resource: "@AppBundle/Controller/SerieFestivalController.php" + type: annotation + fos_user_profile: resource: "@FOSUserBundle/Resources/config/routing/profile.xml" diff --git a/assets/css/pages/_dashboard.scss b/assets/css/pages/_dashboard.scss index c277cdcc..6ea57109 100755 --- a/assets/css/pages/_dashboard.scss +++ b/assets/css/pages/_dashboard.scss @@ -91,3 +91,7 @@ margin-left: 1em; } } +#not_loaded{ + width: 100%; + height: 75vh; +} diff --git a/assets/css/pages/global.scss b/assets/css/pages/global.scss index 13592679..f511ce3f 100755 --- a/assets/css/pages/global.scss +++ b/assets/css/pages/global.scss @@ -64,9 +64,10 @@ body { height: 4em; padding: 1em; box-sizing: border-box; - position: absolute; + position: static; width: 100%; bottom: 0; + display: block; } thead { diff --git a/src/AppBundle/Controller/SerieFestivalController.php b/src/AppBundle/Controller/SerieFestivalController.php new file mode 100644 index 00000000..715ea9a4 --- /dev/null +++ b/src/AppBundle/Controller/SerieFestivalController.php @@ -0,0 +1,140 @@ +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() + ; + } +} diff --git a/src/AppBundle/Entity/Festival.php b/src/AppBundle/Entity/Festival.php index 79163ba5..f49b9f2a 100755 --- a/src/AppBundle/Entity/Festival.php +++ b/src/AppBundle/Entity/Festival.php @@ -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(); diff --git a/src/AppBundle/Form/FestivalType.php b/src/AppBundle/Form/FestivalType.php index a1d7bead..c7cf9214 100755 --- a/src/AppBundle/Form/FestivalType.php +++ b/src/AppBundle/Form/FestivalType.php @@ -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' ) diff --git a/src/AppBundle/Form/ProductCategoryType.php b/src/AppBundle/Form/ProductCategoryType.php index 2d04ac2f..d81e387c 100755 --- a/src/AppBundle/Form/ProductCategoryType.php +++ b/src/AppBundle/Form/ProductCategoryType.php @@ -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'; + } } diff --git a/src/AppBundle/Form/ProductType.php b/src/AppBundle/Form/ProductType.php index 5b5ddc7a..31e76395 100755 --- a/src/AppBundle/Form/ProductType.php +++ b/src/AppBundle/Form/ProductType.php @@ -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', ] ); } ); diff --git a/src/AppBundle/Form/SellRecordType.php b/src/AppBundle/Form/SellRecordType.php index e38f13e4..9797bafb 100755 --- a/src/AppBundle/Form/SellRecordType.php +++ b/src/AppBundle/Form/SellRecordType.php @@ -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, + ], + ]); } diff --git a/src/AppBundle/Form/SerieFestivalType.php b/src/AppBundle/Form/SerieFestivalType.php new file mode 100644 index 00000000..6b60cbbb --- /dev/null +++ b/src/AppBundle/Form/SerieFestivalType.php @@ -0,0 +1,51 @@ +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'; + } + + +} diff --git a/src/AppBundle/Tests/Controller/SerieFestivalControllerTest.php b/src/AppBundle/Tests/Controller/SerieFestivalControllerTest.php new file mode 100644 index 00000000..463738ce --- /dev/null +++ b/src/AppBundle/Tests/Controller/SerieFestivalControllerTest.php @@ -0,0 +1,55 @@ +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()); + } + + */ +} diff --git a/translations/messages.en.yml b/translations/messages.en.yml index f2117116..834f4955 100755 --- a/translations/messages.en.yml +++ b/translations/messages.en.yml @@ -8,6 +8,7 @@ menu: history: History import: Import festivals: Festivals + series: Séries products: Products categories: Categories future: Forecast diff --git a/translations/messages.fr.yml b/translations/messages.fr.yml index a417f67c..a55a6d2e 100755 --- a/translations/messages.fr.yml +++ b/translations/messages.fr.yml @@ -7,6 +7,7 @@ menu: history: Historique import: Importer festivals: Festivals + series: Séries products: Produits categories: Catégories future: Prévisionnel