list crud translated
This commit is contained in:
parent
b386d886e6
commit
975adbb340
@ -76,21 +76,13 @@
|
||||
{% else %}
|
||||
<div class="alert alert-info">
|
||||
|
||||
pas d'owner.
|
||||
pas d'owner.
|
||||
</div>
|
||||
{% endif %}
|
||||
<ul>
|
||||
<li class="pull-left">
|
||||
<a class="btn btn-primary" href="{{ path('festival_show', { 'id': festival.id }) }}">voir
|
||||
</a>
|
||||
</li>
|
||||
<li class="pull-left">
|
||||
<a class="btn btn-primary" href="{{ path('festival_edit', { 'id': festival.id }) }}">
|
||||
<i class="fa fa-pencil"></i>
|
||||
Modifier
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="btn btn-primary" href="{{ path('festival_edit', { 'id': festival.id }) }}">
|
||||
<i class="fa fa-pencil"></i>
|
||||
Modifier
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -1,7 +1,14 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Products list</h1>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<h1>Produits</h1></div>
|
||||
<div class="col-xs-6">
|
||||
<a class="btn btn-primary" href="{{ path('product_new') }}">Nouveau produit</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<table class="table-responsive table-striped table table-bordered table-light">
|
||||
<thead class="bg-dark">
|
||||
@ -30,16 +37,9 @@
|
||||
<td>{{ product.stockCount }}</td>
|
||||
<td>{{ product.comment }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="btn btn-default" href="{{ path('product_show', { 'id': product.id }) }}">voir</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-default" href="{{ path('product_edit', { 'id': product.id }) }}">
|
||||
<i class="fa fa-pencil"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="btn btn-default" href="{{ path('product_edit', { 'id': product.id }) }}">
|
||||
<i class="fa fa-pencil"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
@ -48,7 +48,7 @@
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a class="btn btn-primary" href="{{ path('product_new') }}">Nouveau product</a>
|
||||
<a class="btn btn-primary" href="{{ path('product_new') }}">Nouveau produit</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
@ -1,7 +1,14 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Productcategories list</h1>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<h1>Catégorie de produit</h1></div>
|
||||
<div class="col-xs-6">
|
||||
<a class="btn btn-primary" href="{{ path('productcategory_new') }}">Nouvelle catégorie</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<table class="table-responsive table-striped table table-bordered table-light">
|
||||
<thead>
|
||||
@ -22,29 +29,16 @@
|
||||
<td>{{ productCategory.name }}</td>
|
||||
<td>{{ productCategory.products|length }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="btn btn-primary"
|
||||
href="{{ path('productcategory_show', { 'id': productCategory.id }) }}">voir
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary"
|
||||
href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}">
|
||||
<i class="fa fa-pencil"></i>
|
||||
edit
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="btn btn-primary"
|
||||
href="{{ path('productcategory_edit', { 'id': productCategory.id }) }}">
|
||||
<i class="fa fa-pencil"></i>
|
||||
edit
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a class="btn btn-primary" href="{{ path('productcategory_new') }}">Nouveau productCategory</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="btn btn-primary" href="{{ path('productcategory_new') }}">Nouvelle catégorie</a>
|
||||
{% endblock %}
|
||||
|
@ -424,6 +424,7 @@ class DefaultController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* import lots of products at once
|
||||
* @Route("/mass-create", name="mass_create")
|
||||
*/
|
||||
public function massCreateAction(Request $request)
|
||||
@ -456,7 +457,6 @@ class DefaultController extends Controller
|
||||
$boom = explode(':', trim($line));
|
||||
$firstPart = $boom[0];
|
||||
$value = $boom[1];
|
||||
echo "gérer une catégorie nommée: $value";
|
||||
if ($firstPart === 'catégorie' && $value) {
|
||||
// look for category by name
|
||||
if (!isset($myCategoriesByName[$value])) {
|
||||
@ -468,25 +468,25 @@ class DefaultController extends Controller
|
||||
$m->persist($newCateg);
|
||||
$currentCategory = $newCateg; // associate further categories with the newly created one
|
||||
} else {
|
||||
echo " la catégorie existe déjà";
|
||||
// echo " la catégorie existe déjà";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// manage product
|
||||
echo "<br/> $line";
|
||||
$boom = explode(';', $line);
|
||||
$productName = $boom[0];
|
||||
$price = 0;
|
||||
if ($boom[1]) {
|
||||
$price = intval(str_replace('€', '', $boom[1]));
|
||||
$price = intval(str_replace('€', '', $boom[1]));// removing euro symbol
|
||||
}
|
||||
// or create new product
|
||||
if ($productName && !isset($myProductsByName[$productName])) {
|
||||
$newProduct = new Product();
|
||||
$newProduct->setCategory($currentCategory)
|
||||
->setName($productName)
|
||||
->setStockCount(500)
|
||||
->setUser($currentUser)
|
||||
->setPrice($price) // removing euro symbol
|
||||
->setPrice($price)
|
||||
;
|
||||
$currentUser->addProduct($newProduct);
|
||||
$m->persist($newProduct);
|
||||
|
@ -37,13 +37,17 @@ class ProductController extends Controller {
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
public function newAction( Request $request ) {
|
||||
$user = $this->getUser();
|
||||
$product = new Product();
|
||||
$product->setUser( $this->getUser() );
|
||||
$product->setUser( $user );
|
||||
$product->setPrice( 1 );
|
||||
$product->setStockCount( 10 );
|
||||
$product->setStockCount( 500 );
|
||||
$form = $this->createForm( 'AppBundle\Form\ProductType', $product );
|
||||
$form->handleRequest( $request );
|
||||
|
||||
$user = $this->getUser();
|
||||
if ( $user && $user->getCategories() ) {
|
||||
$product->setCategory( $user->getCategories()[ 0 ] );
|
||||
}
|
||||
if ( $form->isSubmitted() && $form->isValid() ) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist( $product );
|
||||
@ -66,9 +70,9 @@ class ProductController extends Controller {
|
||||
* @Method("GET")
|
||||
*/
|
||||
public function showAction( Product $product ) {
|
||||
if ( $product->getUser()->getId() !== $this->getUser()->getId() ) {
|
||||
$this->denyAccessUnlessGranted( 'ROLE_ADMIN' );
|
||||
}
|
||||
if ( $product->getUser()->getId() !== $this->getUser()->getId() ) {
|
||||
$this->denyAccessUnlessGranted( 'ROLE_ADMIN' );
|
||||
}
|
||||
$deleteForm = $this->createDeleteForm( $product );
|
||||
if ( $product->getUser()->getId() !== $this->getUser()->getId() ) {
|
||||
|
||||
|
@ -23,19 +23,20 @@ class ProductType extends AbstractType {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||
$builder->add( 'name' )
|
||||
$builder->add( 'name' , null, ['label'=>'Nom'])
|
||||
->add( 'image',
|
||||
null,
|
||||
[ 'label' => 'URL pour image' ] )
|
||||
->add( 'stockCount' )
|
||||
->add( 'price')
|
||||
->add( 'comment' );
|
||||
->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(
|
||||
'The SellRecordType cannot be used without an authenticated user!'
|
||||
);
|
||||
}
|
||||
|
||||
$builder->addEventListener( FormEvents::PRE_SET_DATA,
|
||||
function ( FormEvent $event ) {
|
||||
$form = $event->getForm();
|
||||
@ -48,6 +49,7 @@ class ProductType extends AbstractType {
|
||||
'class' => 'AppBundle:ProductCategory',
|
||||
'placeholder' => '--- catégories ---',
|
||||
'choices' => $categories,
|
||||
'label' => 'Catégorie',
|
||||
] );
|
||||
} );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user