diff --git a/app/Resources/views/default/login-choices.html.twig b/app/Resources/views/default/login-choices.html.twig
index b0689a60..ca4a7642 100755
--- a/app/Resources/views/default/login-choices.html.twig
+++ b/app/Resources/views/default/login-choices.html.twig
@@ -36,6 +36,8 @@
{% endif %}" href="{{ path('productcategory_index') }}">
Catégories
+
+ {{ app.user.categories|length }}
@@ -46,6 +48,7 @@
{% endif %}" href="{{ path('product_index') }}" data-toggle="tab">
Produits
+ {{ app.user.products|length }}
@@ -57,6 +60,7 @@
data-toggle="tab">
Festivals
+ {{ app.user.festivals|length }}
diff --git a/src/AppBundle/Controller/DefaultController.php b/src/AppBundle/Controller/DefaultController.php
index 9cd3b5b2..556a1e6c 100755
--- a/src/AppBundle/Controller/DefaultController.php
+++ b/src/AppBundle/Controller/DefaultController.php
@@ -45,17 +45,17 @@ class DefaultController extends Controller {
$lastFestival = $currentUser->getActiveFestival();
- if(!$lastFestival){
+ 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();
- $recentSells = $sellingRepo->findBy( [], [ 'id' => 'desc' ], 0, 5 );
+ $categRepo = $m->getRepository( 'AppBundle:ProductCategory' );
+ $sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
+ $categories = $categRepo->findAll();
+ $recentSells = $sellingRepo->findBy( [], [ 'id' => 'desc' ], 0, 5 );
return $this->render( 'logged/dashboard.html.twig',
[
@@ -368,28 +368,36 @@ class DefaultController extends Controller {
* @Route("/import", name="import")
*/
public function importAction() {
- $currentUser = $this->getUser();
- $m = $this->getDoctrine()->getManager();
- $sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
- $mySellings = $sellingRepo->findByUser( $currentUser->getId() );
+ $currentUser = $this->getUser();
+ $m = $this->getDoctrine()->getManager();
+ $sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
+ $mySellings = $sellingRepo->findByUser( $currentUser->getId() );
return $this->render( 'logged/import.html.twig',
[
- 'base_dir' => '',
+ 'base_dir' => '',
] );
}
+
/**
* @Route("/mass-create", name="mass_create")
*/
- public function massCreateAction() {
- $currentUser = $this->getUser();
- $m = $this->getDoctrine()->getManager();
- $sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
- $mySellings = $sellingRepo->findByUser( $currentUser->getId() );
+ public function massCreateAction( Request $request ) {
+ $currentUser = $this->getUser();
+ $m = $this->getDoctrine()->getManager();
+ $sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
+ $myCategories = $sellingRepo->findByUser( $currentUser->getId() );
+
+ if ( $request->getMethod() == 'POST' ) {
+
+ var_dump( nl2br($request->request->get( 'produits' )) );
+ // check with existing categories and products, sort them by name.
+ // save all
+ }
return $this->render( 'logged/import.html.twig',
[
- 'base_dir' => '',
+ 'base_dir' => '',
] );
}
diff --git a/src/AppBundle/Controller/ProductCategoryController.php b/src/AppBundle/Controller/ProductCategoryController.php
index a0744033..3e2122df 100755
--- a/src/AppBundle/Controller/ProductCategoryController.php
+++ b/src/AppBundle/Controller/ProductCategoryController.php
@@ -39,16 +39,19 @@ class ProductCategoryController extends Controller {
*/
public function newAction( Request $request ) {
$productCategory = new Productcategory();
- $productCategory->setUsers($this->getUser());
- $form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
+ $currentUser = $this->getUser();
+ $currentUser->addCategory( $productCategory );
+ $productCategory->setUsers( [ $currentUser ] );
+ $form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
$form->handleRequest( $request );
if ( $form->isSubmitted() && $form->isValid() ) {
$em = $this->getDoctrine()->getManager();
$em->persist( $productCategory );
+ $em->persist( $currentUser );
$em->flush();
- return $this->redirectToRoute( 'productcategory_show', [ 'id' => $productCategory->getId() ] );
+ return $this->redirectToRoute( 'productcategory_index' );
}
return $this->render( 'productcategory/new.html.twig',