nicer cruds
This commit is contained in:
parent
d5ef71f734
commit
c66aa69037
|
@ -11,11 +11,14 @@
|
||||||
{% block navigation %}
|
{% block navigation %}
|
||||||
{% include 'default/login-choices.html.twig' %}
|
{% include 'default/login-choices.html.twig' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="well">
|
<div class="well">
|
||||||
Votre caisse mobile en ligne
|
Votre caisse mobile en ligne
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
</div>
|
||||||
{% block javascripts %}
|
{% block javascripts %}
|
||||||
<script src="{{ asset('build/app.js') }}"></script>
|
<script src="{{ asset('build/app.js') }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -4,10 +4,27 @@
|
||||||
<div class="well">
|
<div class="well">
|
||||||
<div class="login-choices">
|
<div class="login-choices">
|
||||||
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
|
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-6">
|
||||||
|
<a class="btn btn-default" href="{{ path('homepage') }}">
|
||||||
|
|
||||||
|
<i class="fa fa-home"></i>
|
||||||
|
Caisse
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-default" href="{{ path('dashboard') }}">
|
||||||
|
<i class="fa fa-list"></i>
|
||||||
|
Dashboard
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-6 text-right">
|
||||||
{{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} |
|
{{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} |
|
||||||
<a class="btn btn-default" href="{{ path('fos_user_security_logout') }}">
|
<a class="btn btn-default" href="{{ path('fos_user_security_logout') }}">
|
||||||
{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
|
{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
|
||||||
</a>
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="btn btn-default btn-block btn-twitter" href="{{ hwi_oauth_login_url('google') }}">
|
<a class="btn btn-default btn-block btn-twitter" href="{{ hwi_oauth_login_url('google') }}">
|
||||||
<i class="fa fa-google"></i>
|
<i class="fa fa-google"></i>
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Festival edit</h1>
|
||||||
|
|
||||||
|
{{ form_start(edit_form) }}
|
||||||
|
{{ form_widget(edit_form) }}
|
||||||
|
<input type="submit" value="Edit" />
|
||||||
|
{{ form_end(edit_form) }}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('festival_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,41 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Festivals list</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Datecreation</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for festival in festivals %}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{ path('festival_show', { 'id': festival.id }) }}">{{ festival.id }}</a></td>
|
||||||
|
<td>{{ festival.name }}</td>
|
||||||
|
<td>{% if festival.dateCreation %}{{ festival.dateCreation|date('Y-m-d H:i:s') }}{% endif %}</td>
|
||||||
|
<td>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('festival_show', { 'id': festival.id }) }}">show</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('festival_edit', { 'id': festival.id }) }}">edit</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('festival_new') }}">Create a new festival</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Festival creation</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
<input type="submit" value="Create" />
|
||||||
|
{{ form_end(form) }}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('festival_index') }}">Back to the list</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,36 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Festival</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<td>{{ festival.id }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<td>{{ festival.name }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Datecreation</th>
|
||||||
|
<td>{% if festival.dateCreation %}{{ festival.dateCreation|date('Y-m-d H:i:s') }}{% endif %}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('festival_index') }}">Back to the list</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('festival_edit', { 'id': festival.id }) }}">Edit</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{{ form_start(delete_form) }}
|
||||||
|
<input type="submit" value="Delete">
|
||||||
|
{{ form_end(delete_form) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -62,8 +62,14 @@
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<h3 >Total: <strong>{{CurrentSellingTotal()}}€</strong></h3>
|
<h3 >Total: <strong>{{CurrentSellingTotal()}}€</strong></h3>
|
||||||
<input type="number" id="paid_amount" ng-model="paidAmount">
|
<input type="number" id="paid_amount" ng-model="paidAmount">
|
||||||
|
<div class="alert alert-success" ng-if="CurrentSellingTotal() - paidAmount <=0">
|
||||||
<h3>Rendu: {{ CurrentSellingTotal() - paidAmount }}€</h3>
|
<h3>Rendu: {{ CurrentSellingTotal() - paidAmount }}€</h3>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="alert alert-warning" ng-if="CurrentSellingTotal() - paidAmount >0">
|
||||||
|
<h3>il manque: {{ CurrentSellingTotal() - paidAmount }}€</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endverbatim %}
|
{% endverbatim %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
<a href="#caisse-now" data-toggle="tab">Caisse</a>
|
<a href="#caisse-now" data-toggle="tab">Caisse</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#categories" data-toggle="tab">Catégories</a>
|
<a href="{{ path('productcategory_index') }}">Catégories</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#products" data-toggle="tab">Produits</a>
|
<a href="{{ path('product_index') }}" data-toggle="tab">Produits</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#history" data-toggle="tab">Historique</a>
|
<a href="#history" data-toggle="tab">Historique</a>
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Product edit</h1>
|
||||||
|
|
||||||
|
{{ form_start(edit_form) }}
|
||||||
|
{{ form_widget(edit_form) }}
|
||||||
|
<input type="submit" value="Edit" />
|
||||||
|
{{ form_end(edit_form) }}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('product_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,16 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Product creation</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
<input type="submit" value="Create" />
|
||||||
|
{{ form_end(form) }}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('product_index') }}">Back to the list</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,44 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Product</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<td>{{ product.id }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<td>{{ product.name }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Image</th>
|
||||||
|
<td>{{ product.image }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Price</th>
|
||||||
|
<td>{{ product.price }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Comment</th>
|
||||||
|
<td>{{ product.comment }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('product_index') }}">Back to the list</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('product_edit', { 'id': product.id }) }}">Edit</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{{ form_start(delete_form) }}
|
||||||
|
<input type="submit" value="Delete">
|
||||||
|
{{ form_end(delete_form) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Productcategory edit</h1>
|
||||||
|
|
||||||
|
{{ form_start(edit_form) }}
|
||||||
|
{{ form_widget(edit_form) }}
|
||||||
|
<input type="submit" value="Edit" />
|
||||||
|
{{ form_end(edit_form) }}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('productcategory_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,39 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Productcategories list</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for productCategory in productCategories %}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{{ path('productcategory_show', { 'id': productCategory.id }) }}">{{ productCategory.id }}</a></td>
|
||||||
|
<td>{{ productCategory.name }}</td>
|
||||||
|
<td>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('productcategory_show', { 'id': productCategory.id }) }}">show</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}">edit</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('productcategory_new') }}">Create a new productCategory</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Productcategory creation</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
<input type="submit" value="Create" />
|
||||||
|
{{ form_end(form) }}
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('productcategory_index') }}">Back to the list</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,32 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<h1>Productcategory</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<td>{{ productCategory.id }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<td>{{ productCategory.name }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('productcategory_index') }}">Back to the list</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}">Edit</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{{ form_start(delete_form) }}
|
||||||
|
<input type="submit" value="Delete">
|
||||||
|
{{ form_end(delete_form) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
|
@ -3,3 +3,7 @@
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
|
@ -5,30 +5,30 @@ namespace AppBundle\Controller;
|
||||||
use AppBundle\Entity\ProductCategory;
|
use AppBundle\Entity\ProductCategory;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Productcategory controller.
|
* Productcategory controller.
|
||||||
*
|
*
|
||||||
* @Route("productcategory")
|
* @Route("productcategory")
|
||||||
*/
|
*/
|
||||||
class ProductCategoryController extends Controller
|
class ProductCategoryController extends Controller {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Lists all productCategory entities.
|
* Lists all productCategory entities.
|
||||||
*
|
*
|
||||||
* @Route("/", name="productcategory_index")
|
* @Route("/", name="productcategory_index")
|
||||||
* @Method("GET")
|
* @Method("GET")
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction() {
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$productCategories = $em->getRepository( 'AppBundle:ProductCategory' )->findAll();
|
$productCategories = $em->getRepository( 'AppBundle:ProductCategory' )->findAll();
|
||||||
|
|
||||||
return $this->render('productcategory/index.html.twig', array(
|
return $this->render( 'productcategory/index.html.twig',
|
||||||
|
[
|
||||||
'productCategories' => $productCategories,
|
'productCategories' => $productCategories,
|
||||||
));
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,8 +37,7 @@ class ProductCategoryController extends Controller
|
||||||
* @Route("/new", name="productcategory_new")
|
* @Route("/new", name="productcategory_new")
|
||||||
* @Method({"GET", "POST"})
|
* @Method({"GET", "POST"})
|
||||||
*/
|
*/
|
||||||
public function newAction(Request $request)
|
public function newAction( Request $request ) {
|
||||||
{
|
|
||||||
$productCategory = new Productcategory();
|
$productCategory = new Productcategory();
|
||||||
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
||||||
$form->handleRequest( $request );
|
$form->handleRequest( $request );
|
||||||
|
@ -48,13 +47,14 @@ class ProductCategoryController extends Controller
|
||||||
$em->persist( $productCategory );
|
$em->persist( $productCategory );
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute('productcategory_show', array('id' => $productCategory->getId()));
|
return $this->redirectToRoute( 'productcategory_show', [ 'id' => $productCategory->getId() ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('productcategory/new.html.twig', array(
|
return $this->render( 'productcategory/new.html.twig',
|
||||||
|
[
|
||||||
'productCategory' => $productCategory,
|
'productCategory' => $productCategory,
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
));
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,14 +63,14 @@ class ProductCategoryController extends Controller
|
||||||
* @Route("/{id}", name="productcategory_show")
|
* @Route("/{id}", name="productcategory_show")
|
||||||
* @Method("GET")
|
* @Method("GET")
|
||||||
*/
|
*/
|
||||||
public function showAction(ProductCategory $productCategory)
|
public function showAction( ProductCategory $productCategory ) {
|
||||||
{
|
|
||||||
$deleteForm = $this->createDeleteForm( $productCategory );
|
$deleteForm = $this->createDeleteForm( $productCategory );
|
||||||
|
|
||||||
return $this->render('productcategory/show.html.twig', array(
|
return $this->render( 'productcategory/show.html.twig',
|
||||||
|
[
|
||||||
'productCategory' => $productCategory,
|
'productCategory' => $productCategory,
|
||||||
'delete_form' => $deleteForm->createView(),
|
'delete_form' => $deleteForm->createView(),
|
||||||
));
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,8 +79,7 @@ class ProductCategoryController extends Controller
|
||||||
* @Route("/{id}/edit", name="productcategory_edit")
|
* @Route("/{id}/edit", name="productcategory_edit")
|
||||||
* @Method({"GET", "POST"})
|
* @Method({"GET", "POST"})
|
||||||
*/
|
*/
|
||||||
public function editAction(Request $request, ProductCategory $productCategory)
|
public function editAction( Request $request, ProductCategory $productCategory ) {
|
||||||
{
|
|
||||||
$deleteForm = $this->createDeleteForm( $productCategory );
|
$deleteForm = $this->createDeleteForm( $productCategory );
|
||||||
$editForm = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
$editForm = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
||||||
$editForm->handleRequest( $request );
|
$editForm->handleRequest( $request );
|
||||||
|
@ -88,14 +87,15 @@ class ProductCategoryController extends Controller
|
||||||
if ( $editForm->isSubmitted() && $editForm->isValid() ) {
|
if ( $editForm->isSubmitted() && $editForm->isValid() ) {
|
||||||
$this->getDoctrine()->getManager()->flush();
|
$this->getDoctrine()->getManager()->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute('productcategory_edit', array('id' => $productCategory->getId()));
|
return $this->redirectToRoute( 'productcategory_edit', [ 'id' => $productCategory->getId() ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('productcategory/edit.html.twig', array(
|
return $this->render( 'productcategory/edit.html.twig',
|
||||||
|
[
|
||||||
'productCategory' => $productCategory,
|
'productCategory' => $productCategory,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
'delete_form' => $deleteForm->createView(),
|
'delete_form' => $deleteForm->createView(),
|
||||||
));
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,8 +104,7 @@ class ProductCategoryController extends Controller
|
||||||
* @Route("/{id}", name="productcategory_delete")
|
* @Route("/{id}", name="productcategory_delete")
|
||||||
* @Method("DELETE")
|
* @Method("DELETE")
|
||||||
*/
|
*/
|
||||||
public function deleteAction(Request $request, ProductCategory $productCategory)
|
public function deleteAction( Request $request, ProductCategory $productCategory ) {
|
||||||
{
|
|
||||||
$form = $this->createDeleteForm( $productCategory );
|
$form = $this->createDeleteForm( $productCategory );
|
||||||
$form->handleRequest( $request );
|
$form->handleRequest( $request );
|
||||||
|
|
||||||
|
@ -125,12 +124,10 @@ class ProductCategoryController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\Form\Form The form
|
* @return \Symfony\Component\Form\Form The form
|
||||||
*/
|
*/
|
||||||
private function createDeleteForm(ProductCategory $productCategory)
|
private function createDeleteForm( ProductCategory $productCategory ) {
|
||||||
{
|
|
||||||
return $this->createFormBuilder()
|
return $this->createFormBuilder()
|
||||||
->setAction($this->generateUrl('productcategory_delete', array('id' => $productCategory->getId())))
|
->setAction( $this->generateUrl( 'productcategory_delete', [ 'id' => $productCategory->getId() ] ) )
|
||||||
->setMethod( 'DELETE' )
|
->setMethod( 'DELETE' )
|
||||||
->getForm()
|
->getForm();
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@ class ProductCategory {
|
||||||
*/
|
*/
|
||||||
private $users;
|
private $users;
|
||||||
|
|
||||||
|
public function __toString() {
|
||||||
|
return $this->getName() . ' (' . count( $this->getProducts() ) . ' produits)';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,29 +6,29 @@ use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class ProductType extends AbstractType
|
class ProductType extends AbstractType {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||||
{
|
$builder->add( 'name' )->add( 'image',
|
||||||
$builder->add('name')->add('image')->add('price')->add('comment')->add('category')->add('user');
|
null,
|
||||||
}/**
|
[ 'label' => 'URL pour image' ] )->add( 'price' )->add( 'comment' )->add( 'category' )->add( 'user' );
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
|
||||||
{
|
|
||||||
$resolver->setDefaults(array(
|
|
||||||
'data_class' => 'AppBundle\Entity\Product'
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getBlockPrefix()
|
public function configureOptions( OptionsResolver $resolver ) {
|
||||||
{
|
$resolver->setDefaults( [
|
||||||
|
'data_class' => 'AppBundle\Entity\Product',
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getBlockPrefix() {
|
||||||
return 'appbundle_product';
|
return 'appbundle_product';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue