nicer cruds
This commit is contained in:
parent
d5ef71f734
commit
c66aa69037
|
@ -11,11 +11,14 @@
|
|||
{% block navigation %}
|
||||
{% include 'default/login-choices.html.twig' %}
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
|
||||
{% block body %}
|
||||
<div class="well">
|
||||
Votre caisse mobile en ligne
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% block javascripts %}
|
||||
<script src="{{ asset('build/app.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -4,10 +4,27 @@
|
|||
<div class="well">
|
||||
<div class="login-choices">
|
||||
{% 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') }} |
|
||||
<a class="btn btn-default" href="{{ path('fos_user_security_logout') }}">
|
||||
{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% else %}
|
||||
<a class="btn btn-default btn-block btn-twitter" href="{{ hwi_oauth_login_url('google') }}">
|
||||
<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,7 +62,13 @@
|
|||
<div class="text-right">
|
||||
<h3 >Total: <strong>{{CurrentSellingTotal()}}€</strong></h3>
|
||||
<input type="number" id="paid_amount" ng-model="paidAmount">
|
||||
<div class="alert alert-success" ng-if="CurrentSellingTotal() - paidAmount <=0">
|
||||
<h3>Rendu: {{ CurrentSellingTotal() - paidAmount }}€</h3>
|
||||
</div>
|
||||
<div class="alert alert-warning" ng-if="CurrentSellingTotal() - paidAmount >0">
|
||||
<h3>il manque: {{ CurrentSellingTotal() - paidAmount }}€</h3>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% endverbatim %}
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
<a href="#caisse-now" data-toggle="tab">Caisse</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#categories" data-toggle="tab">Catégories</a>
|
||||
<a href="{{ path('productcategory_index') }}">Catégories</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#products" data-toggle="tab">Produits</a>
|
||||
<a href="{{ path('product_index') }}" data-toggle="tab">Produits</a>
|
||||
</li>
|
||||
<li>
|
||||
<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;
|
||||
}
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
@ -5,30 +5,30 @@ namespace AppBundle\Controller;
|
|||
use AppBundle\Entity\ProductCategory;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
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.
|
||||
*
|
||||
* @Route("productcategory")
|
||||
*/
|
||||
class ProductCategoryController extends Controller
|
||||
{
|
||||
class ProductCategoryController extends Controller {
|
||||
/**
|
||||
* Lists all productCategory entities.
|
||||
*
|
||||
* @Route("/", name="productcategory_index")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
public function indexAction() {
|
||||
$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,
|
||||
));
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,24 +37,24 @@ class ProductCategoryController extends Controller
|
|||
* @Route("/new", name="productcategory_new")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function newAction(Request $request)
|
||||
{
|
||||
public function newAction( Request $request ) {
|
||||
$productCategory = new Productcategory();
|
||||
$form = $this->createForm('AppBundle\Form\ProductCategoryType', $productCategory);
|
||||
$form->handleRequest($request);
|
||||
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
||||
$form->handleRequest( $request );
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
if ( $form->isSubmitted() && $form->isValid() ) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($productCategory);
|
||||
$em->persist( $productCategory );
|
||||
$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,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,14 +63,14 @@ class ProductCategoryController extends Controller
|
|||
* @Route("/{id}", name="productcategory_show")
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function showAction(ProductCategory $productCategory)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($productCategory);
|
||||
public function showAction( ProductCategory $productCategory ) {
|
||||
$deleteForm = $this->createDeleteForm( $productCategory );
|
||||
|
||||
return $this->render('productcategory/show.html.twig', array(
|
||||
return $this->render( 'productcategory/show.html.twig',
|
||||
[
|
||||
'productCategory' => $productCategory,
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,23 +79,23 @@ class ProductCategoryController extends Controller
|
|||
* @Route("/{id}/edit", name="productcategory_edit")
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function editAction(Request $request, ProductCategory $productCategory)
|
||||
{
|
||||
$deleteForm = $this->createDeleteForm($productCategory);
|
||||
$editForm = $this->createForm('AppBundle\Form\ProductCategoryType', $productCategory);
|
||||
$editForm->handleRequest($request);
|
||||
public function editAction( Request $request, ProductCategory $productCategory ) {
|
||||
$deleteForm = $this->createDeleteForm( $productCategory );
|
||||
$editForm = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
|
||||
$editForm->handleRequest( $request );
|
||||
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
if ( $editForm->isSubmitted() && $editForm->isValid() ) {
|
||||
$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,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
));
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,18 +104,17 @@ class ProductCategoryController extends Controller
|
|||
* @Route("/{id}", name="productcategory_delete")
|
||||
* @Method("DELETE")
|
||||
*/
|
||||
public function deleteAction(Request $request, ProductCategory $productCategory)
|
||||
{
|
||||
$form = $this->createDeleteForm($productCategory);
|
||||
$form->handleRequest($request);
|
||||
public function deleteAction( Request $request, ProductCategory $productCategory ) {
|
||||
$form = $this->createDeleteForm( $productCategory );
|
||||
$form->handleRequest( $request );
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
if ( $form->isSubmitted() && $form->isValid() ) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($productCategory);
|
||||
$em->remove( $productCategory );
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('productcategory_index');
|
||||
return $this->redirectToRoute( 'productcategory_index' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,12 +124,10 @@ class ProductCategoryController extends Controller
|
|||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm(ProductCategory $productCategory)
|
||||
{
|
||||
private function createDeleteForm( ProductCategory $productCategory ) {
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('productcategory_delete', array('id' => $productCategory->getId())))
|
||||
->setMethod('DELETE')
|
||||
->getForm()
|
||||
;
|
||||
->setAction( $this->generateUrl( 'productcategory_delete', [ 'id' => $productCategory->getId() ] ) )
|
||||
->setMethod( 'DELETE' )
|
||||
->getForm();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ class ProductCategory {
|
|||
*/
|
||||
private $users;
|
||||
|
||||
public function __toString() {
|
||||
return $this->getName() . ' (' . count( $this->getProducts() ) . ' produits)';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
|
@ -6,29 +6,29 @@ use Symfony\Component\Form\AbstractType;
|
|||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ProductType extends AbstractType
|
||||
{
|
||||
class ProductType extends AbstractType {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('name')->add('image')->add('price')->add('comment')->add('category')->add('user');
|
||||
}/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'AppBundle\Entity\Product'
|
||||
));
|
||||
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||
$builder->add( 'name' )->add( 'image',
|
||||
null,
|
||||
[ 'label' => 'URL pour image' ] )->add( 'price' )->add( 'comment' )->add( 'category' )->add( 'user' );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
public function configureOptions( OptionsResolver $resolver ) {
|
||||
$resolver->setDefaults( [
|
||||
'data_class' => 'AppBundle\Entity\Product',
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix() {
|
||||
return 'appbundle_product';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue