choix de festival actuel ok

This commit is contained in:
Kayn Ty 2018-04-18 15:42:30 +02:00
parent ffa183fa38
commit 43f9299aaa
5 changed files with 77 additions and 36 deletions

View File

@ -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>

View File

@ -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 %}

View File

@ -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>

View File

@ -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">

View File

@ -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' );
}
}