diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index c1c8cef1..faab7362 100755 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -19,9 +19,10 @@ <div id="bodyland"> <div class="container"> {% include 'default/header.html.twig' %} + {% block body %} + {% endblock %} </div> - {% block body %} - {% endblock %} + </div> {% block javascripts %} <script src="{{ asset('build/app.js') }}"></script> diff --git a/app/Resources/views/festival/index.html.twig b/app/Resources/views/festival/index.html.twig index 530fbab6..89f7a88e 100755 --- a/app/Resources/views/festival/index.html.twig +++ b/app/Resources/views/festival/index.html.twig @@ -1,7 +1,14 @@ {% extends 'base.html.twig' %} {% block body %} - <h1>Festivals list</h1> + <div class="row"> + <div class="col-xs-6"> + <h1>Festivals</h1></div> + <div class="col-xs-6"> + <a class="btn btn-primary" href="{{ path('festival_new') }}">Nouveau festival</a> + </div> + </div> + <table class="table-responsive table-striped table table-bordered table-light"> <thead> @@ -9,6 +16,10 @@ <th>Id</th> <th>Name</th> <th>Datecreation</th> + <th>Clients</th> + <th>fond caisse avant</th> + <th>fond caisse apres</th> + <th>chiffre affaire</th> <th>Actions</th> </tr> </thead> @@ -21,8 +32,18 @@ </td> <td>{{ festival.name }}</td> <td>{% if festival.dateCreation %}{{ festival.dateCreation|date('Y-m-d H:i:s') }}{% endif %}</td> + + <td>{{ festival.sellRecords|length }}</td> + <td>{{ festival.fondDeCaisseAvant }}</td> + <td>{{ festival.fondDeCaisseApres }}</td> + <td>{{ festival.chiffreAffaire }}</td> <td> <ul> + <li> + <a class="btn btn-success" href="{{ path('set_active_festival', { 'id': festival.id }) }}"> + choisir comme actuel + </a> + </li> <li> <a class="btn btn-primary" href="{{ path('festival_show', { 'id': festival.id }) }}">voir </a> @@ -30,6 +51,7 @@ <li> <a class="btn btn-primary" href="{{ path('festival_edit', { 'id': festival.id }) }}"> <i class="fa fa-pencil"></i> + Modifier </a> </li> </ul> @@ -39,9 +61,5 @@ </tbody> </table> - <ul> - <li> - <a class="btn btn-primary" href="{{ path('festival_new') }}">Nouveau festival</a> - </li> - </ul> + <a class="btn btn-primary" href="{{ path('festival_new') }}">Nouveau festival</a> {% endblock %} diff --git a/app/Resources/views/logged/angular/loaded-caisse.html.twig b/app/Resources/views/logged/angular/loaded-caisse.html.twig index a4e4afe9..7a841baf 100755 --- a/app/Resources/views/logged/angular/loaded-caisse.html.twig +++ b/app/Resources/views/logged/angular/loaded-caisse.html.twig @@ -10,16 +10,18 @@ </div> <div class="sellings col-xs-5"> -<div class="well"> + <div class="well"> - {% include 'logged/angular/validate-button.html.twig' %} - {% include 'logged/angular/current.html.twig' %} - {#{% include 'logged/angular/paused.html.twig' %}#} -</div> + {% include 'logged/angular/validate-button.html.twig' %} + {% include 'logged/angular/current.html.twig' %} + {#{% include 'logged/angular/paused.html.twig' %}#} + </div> </div> </div> <div id="other_time"> + Festival choisi par l'utilsateur: + {{ app.user.activeFestival.name }} {% include 'logged/angular/recent.html.twig' %} </div> </div> diff --git a/app/Resources/views/logged/dashboard.html.twig b/app/Resources/views/logged/dashboard.html.twig index 1d3cae42..04b97f26 100755 --- a/app/Resources/views/logged/dashboard.html.twig +++ b/app/Resources/views/logged/dashboard.html.twig @@ -6,7 +6,6 @@ <div id="caisse-now" class="tab-pane fade in active"> - {% include 'default/header.html.twig' %} {% include 'logged/caisse-main.html.twig' %} </div> <div id="categories" class="tab-pane fade"> diff --git a/src/AppBundle/Controller/DefaultController.php b/src/AppBundle/Controller/DefaultController.php index cca86721..88f5a2cb 100755 --- a/src/AppBundle/Controller/DefaultController.php +++ b/src/AppBundle/Controller/DefaultController.php @@ -43,11 +43,15 @@ class DefaultController extends Controller { $m = $this->getDoctrine()->getManager(); $currentUser = $this->getUser(); - $lastFestival = $m->getRepository( 'AppBundle:Festival' ) - ->findOneBy( [ 'user' => $this->getUser()->getId() ], - [ 'id' => 'desc' ], - 0, - 1 ); + + $lastFestival = $currentUser->getActiveFestival(); + if(!$lastFestival){ + $lastFestival = $m->getRepository( 'AppBundle:Festival' ) + ->findOneBy( [ 'user' => $this->getUser()->getId() ], + [ 'id' => 'desc' ], + 0, + 1 ); + } $categRepo = $m->getRepository( 'AppBundle:ProductCategory' ); $sellingRepo = $m->getRepository( 'AppBundle:SellRecord' ); $categories = $categRepo->findAll(); @@ -80,23 +84,23 @@ class DefaultController extends Controller { } $activeFestival = $currentUser->getActiveFestival(); - if ( ! $activeFestival ) { - $activeFestival = $m->getRepository( 'AppBundle:Festival' ) - ->findOneBy( [ 'user' => $this->getUser()->getId() ], - [ 'id' => 'desc' ], - 0, - 1 ); - if ( ! $activeFestival ) { - $activeFestival = new Festival(); - $activeFestival->setDateCreation( new \DateTime() ); - $activeFestival->setName( 'default festival' ); - $activeFestival->setUser( $currentUser ); - } - $currentUser->setActiveFestival( $activeFestival ); - $m->persist( $activeFestival ); - $m->persist( $currentUser ); - $m->flush(); - } +// if ( ! $activeFestival ) { +// $activeFestival = $m->getRepository( 'AppBundle:Festival' ) +// ->findOneBy( [ 'user' => $this->getUser()->getId() ], +// [ 'id' => 'desc' ], +// 0, +// 1 ); +// if ( ! $activeFestival ) { +// $activeFestival = new Festival(); +// $activeFestival->setDateCreation( new \DateTime() ); +// $activeFestival->setName( 'default festival' ); +// $activeFestival->setUser( $currentUser ); +// } +// $currentUser->setActiveFestival( $activeFestival ); +// $m->persist( $activeFestival ); +// $m->persist( $currentUser ); +// $m->flush(); +// } $categRepo = $m->getRepository( 'AppBundle:ProductCategory' ); @@ -342,4 +346,21 @@ class DefaultController extends Controller { ] ); } + + + /** + * @Route("/set-active-festival/{id}", name="set_active_festival") + */ + public function setActiveFestivalAction( $id ) { + $currentUser = $this->getUser(); + $m = $this->getDoctrine()->getManager(); + $repo = $m->getRepository( 'AppBundle:Festival' ); + + $currentUser->setActiveFestival( $repo->find( $id ) ); + $m->persist( $currentUser ); + $m->flush(); + + // replace this example code with whatever you need + return $this->redirectToRoute( 'dashboard' ); + } }