counting stuff

This commit is contained in:
Kayn Ty 2018-04-19 11:41:05 +02:00
parent e76d6ec225
commit 922fa73e94
3 changed files with 34 additions and 19 deletions

View File

@ -36,6 +36,8 @@
{% endif %}" href="{{ path('productcategory_index') }}"> {% endif %}" href="{{ path('productcategory_index') }}">
<i class="fa fa-file-archive-o"></i> <i class="fa fa-file-archive-o"></i>
Catégories Catégories
{{ app.user.categories|length }}
</a> </a>
</li> </li>
<li> <li>
@ -46,6 +48,7 @@
{% endif %}" href="{{ path('product_index') }}" data-toggle="tab"> {% endif %}" href="{{ path('product_index') }}" data-toggle="tab">
<i class="fa fa-gears"></i> <i class="fa fa-gears"></i>
Produits Produits
{{ app.user.products|length }}
</a> </a>
</li> </li>
<li> <li>
@ -57,6 +60,7 @@
data-toggle="tab"> data-toggle="tab">
<i class="fa fa-th-large"></i> <i class="fa fa-th-large"></i>
Festivals Festivals
{{ app.user.festivals|length }}
</a> </a>
</li> </li>
<li> <li>

View File

@ -45,7 +45,7 @@ class DefaultController extends Controller {
$lastFestival = $currentUser->getActiveFestival(); $lastFestival = $currentUser->getActiveFestival();
if(!$lastFestival){ if ( ! $lastFestival ) {
$lastFestival = $m->getRepository( 'AppBundle:Festival' ) $lastFestival = $m->getRepository( 'AppBundle:Festival' )
->findOneBy( [ 'user' => $this->getUser()->getId() ], ->findOneBy( [ 'user' => $this->getUser()->getId() ],
[ 'id' => 'desc' ], [ 'id' => 'desc' ],
@ -378,14 +378,22 @@ class DefaultController extends Controller {
'base_dir' => '', 'base_dir' => '',
] ); ] );
} }
/** /**
* @Route("/mass-create", name="mass_create") * @Route("/mass-create", name="mass_create")
*/ */
public function massCreateAction() { public function massCreateAction( Request $request ) {
$currentUser = $this->getUser(); $currentUser = $this->getUser();
$m = $this->getDoctrine()->getManager(); $m = $this->getDoctrine()->getManager();
$sellingRepo = $m->getRepository( 'AppBundle:SellRecord' ); $sellingRepo = $m->getRepository( 'AppBundle:SellRecord' );
$mySellings = $sellingRepo->findByUser( $currentUser->getId() ); $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', return $this->render( 'logged/import.html.twig',
[ [

View File

@ -39,16 +39,19 @@ class ProductCategoryController extends Controller {
*/ */
public function newAction( Request $request ) { public function newAction( Request $request ) {
$productCategory = new Productcategory(); $productCategory = new Productcategory();
$productCategory->setUsers($this->getUser()); $currentUser = $this->getUser();
$currentUser->addCategory( $productCategory );
$productCategory->setUsers( [ $currentUser ] );
$form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory ); $form = $this->createForm( 'AppBundle\Form\ProductCategoryType', $productCategory );
$form->handleRequest( $request ); $form->handleRequest( $request );
if ( $form->isSubmitted() && $form->isValid() ) { if ( $form->isSubmitted() && $form->isValid() ) {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$em->persist( $productCategory ); $em->persist( $productCategory );
$em->persist( $currentUser );
$em->flush(); $em->flush();
return $this->redirectToRoute( 'productcategory_show', [ 'id' => $productCategory->getId() ] ); return $this->redirectToRoute( 'productcategory_index' );
} }
return $this->render( 'productcategory/new.html.twig', return $this->render( 'productcategory/new.html.twig',